Powershell, How do I connect to sql server using sql authentication

motioneye
motioneye used Ask the Experts™
on
Hi,
Currently I'm connected to sql server via Powershell via integrated security as below, how about making a connection with sql authentication ?


 $con = "server=$svr;database=master;Integrated Security=sspi"
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sr. Software Engineer
Commented:
following is a website where you can found all possible strings for db connection.
http://www.connectionstrings.com/
 
Haroon Ur RashidSr. Software Engineer
Commented:
for sql authentication you need this string.
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Commented:
To make a connection using integrated security, you login which you are currently using should be present in the remote SQL Server instance. The syntax you have provided is fine, however, you need to make sure that your login exists in the remote SQL Server instance - then you can make a connection(as this is integrated security)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial