November 28, 2006 at 11:47 am
Is there a way to export a comma delimited file using Query Analyzer?
Thanks in advance.
November 28, 2006 at 12:47 pm
You will want to have the following the first thing in your script to eliminate the count - if not already set >>>>
SET NOCOUNT ON
GO
NOTE: Setp 4 above if set to "results to Text" will show you what will be created in the ouput file.
EXAMPLE:
SET NOCOUNT ON
GO
SP_who2 'active'
November 28, 2006 at 12:56 pm
Is there a way to hardcode the file location into the script that can be used in a stored procedure?
Thanks.
November 28, 2006 at 1:40 pm
You could use xp_cmdshell to call osql: see below>>
USE PUBS
GO
CREATE PROCEDURE ExportTest1
AS
SET NOCOUNT ON
DECLARE @cmd VARCHAR (255)
SET @cmd = 'OSQL -E -S 424XG61\DBA -d Pubs -Q "EXIT(SET NOCOUNT ON SELECT * FROM authors)" > C:\ExportFile.txt'
EXEC master.dbo.XP_cmdshell @cmd, NO_OUTPUT
GO
EXEC ExportTest1
or
use a DTS package using a Transform Data Task. Which would allow you to call a stored procedure or just run a script with a set output file
Not certain anything else is possible with SQL syntax
NOTE: for more on xp_cmdshell or osql see books online which is typically installed by default with MSSQL server (Query Analyzer uses isql)
November 28, 2006 at 11:17 pm
If your DBAs have any self respect they'll have locked down xp_cmdshell so it can't be used.
Since the poster's starting point was QA, it might be simpler to just get osql to run the stored proc from the same (desktop?) environment that QA was run from.
November 29, 2006 at 12:40 am
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply