June 27, 2015 at 7:40 am
I would like to move my AG databases to new location using C#.
I found article on MSDN which uses SQLCmd utility to do that, but I cant run that utility from my application.
I am looking for general steps OR T-SQL if possible so that I can follow the same from my C# application.
Regards
Ashish
June 29, 2015 at 2:51 am
Hi Ashish,
Could you post the URL of the MSDN article that explains the procedure?
Additionally. Do you need to change the database location for the primary and the secondary replicas all together or just one secondary replica?
Best regards,
June 29, 2015 at 3:18 am
Below mention is the MSDN URL..
I would like to change the mdf and ldf file path of AG Databases in all the replicas.
June 29, 2015 at 7:17 am
Are you doing this as a form of Automation?
Just want to understand why you need to use C#?
June 29, 2015 at 7:23 am
We are writing the code for managing SQL server instances from the centralized server.
This is in the interest of storage domain solutions fro SQL server.
We migrate DB to our storage drives from the centralized server.
Regards
Ashish
June 29, 2015 at 7:46 am
Have you looked at using PowerShell at all?
This can be called from within your C# application and PowerShell has AlwaysOn assemblies you could use for the database manipulation?
http://blogs.msdn.com/b/kebab/archive/2014/04/28/executing-powershell-scripts-from-c.aspx
https://msdn.microsoft.com/en-us/library/ff878391.aspx
Maybe incorporate The SQL Scripts you mentioned in your link:
I'm guess your challenge is the SQLCMD commands in the T-SQL Statements,
i.e. connect noode1:
June 29, 2015 at 10:42 am
Hi
Sorry but I do have a test environment with me now but I think that you could try creating temporary linked servers on a master instance and then replace the SQLCMD connect command to other servers on the blog example by using the EXEC ('SQL CODE') AT [Linked Server]
I hope that helps.
Dynamic SQL execution on remote SQL Server using EXEC AT
http://www.mssqltips.com/sqlservertip/1757/dynamic-sql-execution-on-remote-sql-server-using-exec-at/[/url]
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply