Thursday, January 14, 2010

Running SQLCmd – SQL Server

We can use sql query with interface or we can use it with command prompt, on this time i prefer to discuss from command prompt.

With interface, we can run it from :
image

With command prompt we can run it from
image

The script is like this :
For Window Authentication Login
sqlcmd -S server1\SQLExpress

image

For Account Authentication Login
sqlcmd -S server1\SQLExpress -U SqlUserAccount -P SqlPassword

Refer to SqlCmd utility – Case Sensitive format
image 
And we can try for this useful scripts :
SqlCmd Help
sqlcmd /?

Execute query from file
sqlcmd -S myServer\instanceName -i C:\myScript.sql

Save query result on file
sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt

Reference Link
http://msdn.microsoft.com/en-us/library/ms165702.aspx
http://msdn.microsoft.com/en-us/library/ms170572.aspx

No comments:

Hukum Tabur Tuai

Ingatlah hukum dasar ini, dalam kehidupanmu  Barang siapa yang menanam, dia pula yang akan menuai