Wednesday, December 31, 2014

Update SQL Agent jobs to a new job owner

Good Bye... 2014


I dedicated all my 2014 work and script to my little brother, Aung Phyo Tha, who suffers from brain aneurysm and is still unconscious for 46 Days. Please pray for him to wake up very soon. Thank you.

The following script is to update all sql agent jobs to a new owner. I have tested the script and it worked. Please run it in Development first. Enjoy Scripting.....

Declare @Job_ID uniqueidentifier
Declare @sql nvarchar(4000)
Declare @NewJobowner varchar(10)

Set @NewJobowner = 'Domain\newowner'

Declare Job_Csr cursor Local for

select job_id from msdb..sysjobs_view
where enabled = 1

Open Job_Csr;
Fetch Job_Csr into

@job_ID

While @@FETCH_STATUS = 0

Begin


Exec msdb.dbo.sp_update_job @job_id = @job_Id,
@owner_login_name = @Newjobowner


Fetch Job_Csr into
@Job_ID

End

Close Job_Csr
Deallocate Job_Csr

Tuesday, October 28, 2014

How to run Powershell in Windows Task Scheduler

Action : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add Arguments : -noprofile -executionpolicy RemoteSigned -file E:\CopyBakPS\Powershell.ps1


Friday, October 24, 2014

SSRS - Keep header in new pages

In report design mode, click on advanced mode which is down arrow on Column Group pane.



In the RowGroups section you will find "(static)" and "(Details)". In properties,
Keep With Group = After
Repeat On New Page =True



Go back to table, right-click on the row header, and go to tablix properties


Tuesday, October 14, 2014

Win 2012 IP Conflict - Power Management Setting on servers (Possible resolution)

We are having Ip Conflict issues with alwaysOn SQL servers.Below is alert message from SCOM.

Alert description: The system detected an address conflict for IP address XX.XX.XXX.XX with the system
having network hardware address 08-55-56-92-3P-FC. Network operations on this system may
be disrupted as a result


Comment

There is no duplicate ip address on ARP Table. Looks like a failover event if not clearing itself up and throwing this warning.

Issues

It took Cluster Failover manager offline and caused availability group error,


Possible Solution



NIC have setting “Allow the computer to turn off this device to save power” is set, unless somone has a good reason we would want a server NIC to sleep I would suggest this setting be cleared.





Friday, October 10, 2014

SSRS Unattended Execution account

Reporting Services provides a special account that is used for unattended report processing and for sending connection requests across the network. The account is used in the following ways:
·         Send connection requests over the network for reports that use database authentication, or connect to external report data sources that do not require or use authentication. For more information, see Specify Credential and Connection Information for Report Data Sources in SQL Server Books Online.
·         Retrieve external image files that are used in report. If you want to use an image file and the file cannot be accessed through Anonymous access, you can configure the unattended report processing account and grant the account permission to access the file.


http://msdn.microsoft.com/en-us/library/ms156302.aspx




Credentials are encrypted in rsreport config file.

Fix SSRS 2012 Reports were viewed Blank in Chrome and Safari


function pageLoad() { var element = document.getElementById("ctl31_ctl09"); if (element) { element.style.overflow = "visible"; } }

Append the above line in ReportingService.js file under this location

E:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportManager\js


Restart Reporting service

NOTE : ctl31_ctl09 is for SQL 2012. They are different in each version of SQL server.

Friday, September 26, 2014

Starting MONGODB - NoSQL

I heard about MongoDB from a friend and wanted to try out open source database.

Installing Mongo DB

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

I am installing MongoDB on windows 7. I have downloaded windows version from Mogodb website and unpacked msi.


  • move bin folder to C:\MogoDB\
  • create a directory for data - c:\data\db
  • Setting data path
  • c:\mongodb\bin\mongod.exe --dbpath c:\data\db





Starting MongoDB service

Open a command prompt

C:\MongoDB\Bin\Mongod.exe


Waiting for connections on port 27017 means MongoDB service is successfully started.



Open another command Prompt to connect to Mongo Database

Type

C:\mongodb\bin\Mongo.exe

You will see the error that cannot find the file mongorc.js



So you tell the shell to ignore looking for .mongorc.js

C:\MongoDB\Bin\Mongo.exe --norc --shell



Now you are successfully connected to database.

type 

db
it will return test, connecting to test database





use mydb


show collections



Generate test data in a loop


Read inserted data




It was fun to play with MongoDB. More posts will be coming soon...

How to add a Database to AlwaysOn Availability Group with four different options

To add a database to an existing AlwaysOn availability group, MS has given us four options to choose from Automatic seeding Full database an...