How to open sql server management studio by using sql server authenticaion by using vba

venkatesh ks
venkatesh ks used Ask the Experts™
on
Hi Experts,

I am using below code to open ssms by using windows authenticion. But how can i open ssms by using sql server authenticaion via vba. Please anyone tell me the solution.

 Sub Open_ModScript()
    Dim rc
       rc = Shell("ssms.exe -S CHNMCT123456D -d sample -E ")
End Sub

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
Hi,

Maybe
 
Sub Open_ModScript()
     Dim rc
        rc = Shell("ssms.exe -S CHNMCT123456D -d sample -U theUser -P thePW")
 End Sub

Open in new window

Regards

Author

Commented:
Hi,

That code is not working.  I replaced theuser as username, the PW as password. But ssms show dialog box which contain usage.
Top Expert 2016

Commented:
and with
-noSplash
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Author

Commented:
it shows

ssms.exe [-S servername[\instance_name]][-d database][-U user] [-p password] [-E] [-nosplash] [file_name[,file_name]*][-log [file_name]?][?]


and gives meaning from -s to.....[?]

Author

Commented:
HI Rgonzo1971,

I am new for this VB macros. If you give code , i will check it.
Top Expert 2016

Commented:
Didn't quite understand
Top Expert 2016
Commented:
Sub Open_ModScript()
     Dim rc
        rc = Shell("ssms.exe -S CHNMCT123456D -d sample -U theUser -P thePW -nosplash" )
 End Sub

Open in new window

"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
The syntax description shows a lower case -p for the password parameter.
Sub Open_ModScript()
     Dim rc
        rc = Shell("ssms.exe -S CHNMCT123456D -d sample -U theUser -p thePW -nosplash" )
 End Sub

Open in new window

Author

Commented:
in the above code i replaced my server name, database name, userid and password of the server. But it should not work. Sql server management studio shows a dialog box of usage. The usage box contain below code as,

"ssms.exe [-S servername[\instance_name]][-d database][-U user] [-p password] [-E] [-nosplash] [file_name[,file_name]*][-log [file_name]?][?]

[-S the name of the sql server instance to connect to]
...............
..............
[?] displays this usage information"

But the SSMS is not opening automatically by run this vb
Top Expert 2016

Commented:
Sorry can't help further

Author

Commented:
Hello Rgonzo1971,

Do you know how to import xlcsv file into sql server by using VB?
Top Expert 2016

Commented:
Nope

Author

Commented:
Ok

Author

Commented:
Thank You
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Just tested with SSMS 2016 from the cmdline, and it works for me as expected. Even if the DB is wrong (does not exist), SSMS opens up with a connected query window.

Author

Commented:
Hi Qlemo,

How to upload xlcsv file in SSMS by using VB?

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