July 3, 2012 at 9:58 am
Hi SQL Masters,
I used the command line when connecting to SQL Servers and executing T-SQL script, my problem here is how can i set the lines of output? I'm getting very dirty result of query 🙁
Anyone can advise?
Thank you very much!!!
-dev1.bohol
July 3, 2012 at 11:04 am
You are getting too wide of data?
You can increase the size of the command line window and set the width of the result sets, but if the output exceeds those limits in will get messy. Not a whole lot you can do at the command line.
I have to ask why not use SSMS?
CEWII
July 4, 2012 at 7:11 am
Hi,
Thanks for advise, it works on me :-D, regarding your question, it's nothing, i just want to try to execute some scripts on command line 😀
Thank you
-dev1.bohol
July 6, 2012 at 6:59 am
The following is a SQLCMD command that would be used in a .bat file to run the given query(-Q) and send the output to the filename given (after the -o). You can then look at the output at your leisure. (Note: -E means use Windows Authentication)
sqlcmd -S MYServerName -E -Q"USE master; EXEC sp_help_revlogin" -o C:\SQLServer_Logins_Extract\SQLServerLogins\MyServerName_Logins_Extract.sql
To use a file that contains a big sql script, use the following:
sqlcmd -S MyServerName -E -i C:\SomeDirectory\SomeBigSQLScriptFile.sql -o C:\SomeDir\SomeOutputFromBigSQLScriptRun.txt
Hope this helps.
July 6, 2012 at 7:01 am
Darn, I think I misread your post. It's Friday. Brain not functioning. Oh well....
July 6, 2012 at 11:16 am
Thanks everyone 😀 I learned from you all.
-dev1.bohol
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply