0

I want to execute tsql scripts from custom cmdlet written in c#. Can you recommend me the best practice to do it?

I have a few .sql scripts and in my cmdlet I need to iterate through them in specific order and execute each sql script. I also need to run all scripts in transaction if is it possible.

And I need to execute scripts remotely. It means, that there may not be sql server installed on the machine from which is cmdlet executed.

The target sql servers are 2008, 2008R2, 2012.

I have read some approaches, but i'm still not sure what is the best one.

thanks in advance

zosim
  • 2,959
  • 6
  • 31
  • 34
  • Why do you need powershell for it? – Andrey Marchuk Nov 05 '12 at 08:03
  • The aim of this task is to create cmdlets for administration of application. So, i will need to install/uninstall/upgrade application with powershell. The application will have also an installer, which will call these cmdlets. Cmdlets can be called also directly from the console. – zosim Nov 05 '12 at 13:04
  • You can compile it into dll and make cmdlets call this dll. – Andrey Marchuk Nov 05 '12 at 13:13

0 Answers0