Friday, 9 January 2015

Execute Sql query using Command Prompt

//Execute 

sqlcmd -S [Your Sql server name] -U [User_ID] -P [Password] -i [Full_path_of_sql_file_that_will_be_executed] 
ex-

sql file name >  -   D:\main_20150108.sql
Server name >       ABC-PC
User Id         >        sa
Password     >        System@123
Output file   >        D:\main_20150108.txt

//Now open Command prompt using ADMINISTRATOR account

C:\Administrator\systerm32> sqlcmd -S ABC-PC -U sa -P System@123 -i D:\main_20150108.sql


//Execute and get in text file
sqlcmd -S [Your Sql server name] -U [User_ID] -P [Password] -i [Full_path_of_sql_file_that_will_be_executed] -o [full_path_of_output_file_after_sql_executed] 

C:\Administrator\systerm32> sqlcmd -S ABC-PC -U sa -P System@123 -i D:\main_20150108.sql -o D:\main_20150108.txt

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...