I am not looking for anyone to do my "homework". What I need to know is if there is a method or function in MS SQL that is used to dump SQL querys into a text file.
I am not sure if my last message is clear or not but again looking for a crumb not the work.
Here is the code that I have so far:
CODE
-- Save SQL output to OS file sample code BEGIN
SET NOCOUNT ON
DECLARE @msg varchar(200);
DECLARE @file varchar(200);
DECLARE @cmd varchar(500);
SET @msg = 'Hello, there.';
-- define the output file pathname
SET @file = 'C:\IT\Temp\MyTempTest.txt';
-- >, rewrite the file with the message
SET @cmd = 'echo ' + @msg + ' > ' + @file;
-- NO_OUTPUT, do not return any output to the client
EXEC master..xp_cmdshell @cmd, NO_OUTPUT;
SET @msg = 'How are you.';
-- >>, append the message
SET @cmd = 'echo ' + @msg + ' >> ' + @file;
EXEC master..xp_cmdshell @cmd, NO_OUTPUT;
-- Save SQL output to OS file sample code END
What I was looking for was "EXEC master..xp_cmdshell @cmd, NO_OUTPUT" I had no idea that this existed until i stumbled accross it.
Thanks,
This post has been edited by corliss: 2 Jul, 2009 - 10:37 AM