SQL Server, How to easily create a text file with the result of your query (another easy tips)
Hello friends, Its the time for another " useful but fast & easy ” tips! The question of today is: I have a query, a select on my database the "give me" a resultset which I need to export to a text file. How to produce the text file? maybe this operation must be schedulable. So, How to do it? We can take advantage of the SqlCmd command that we have already used here: execute T-SQL commands from the command line Just prepare your select as in the picture below and save it into a .SQL file. Then open a command promp and type: SqlCmd -U xx -P yyyyy -i select.sql -o c:\dati.txt where -U username -P password -i the location of your script -o is the file name that will be filled up with your data! Et voilà! That's all for today I wish you a great day! Luca Previous post: SQL SERVER, One thing you should definitely know about the UPDATE statement ...