Author Posts

May 21, 2014 at 7:27 am

Greetings,

I have requirement to create common connection string to execute all SQL script file or Query and i could not find any example.

Please could you help me get an example or provide some input based on your experience.

This will help to achieve my tasks ..!

using power shell v2.0

Thanks
VJ

May 21, 2014 at 7:40 am

Hi, is it the actual connection string you need help with or how to conect to the database and get data?

If you want to have a connectionstring available for all your scripts you can add the connection string to your $PROFILE. That ensures that is is available for your scripts.

Don Jones have a great example for how you can do this in his code for generating historical reports. The code is available from the OneDrive folder.

May 21, 2014 at 7:55 am

Hi joakim,

Thank you so much for your quick reply.

Hers's the steps i would like to connect database :-

1. Create common script, should have only the connections string info like user/pwd & server & database name with encrypted PWD.

2. Create .ps1 script to call the connection string and then open connection to execute the QUERY or procedure / .sql file

3. close the connection sting in the .ps1 file

4. Done