Write to text file from a sql server stored-procedure
-
hello everyone. I was wondering if someone could help me. As a debugging aid i want to see how many times my stored-proc is called and i also want to record certain variables. I would like to write this information to a text file on c:\ of the SQL Server. I am using MS Sql Server 2000.. Can anyone point me in the right direction please. Thanks
-
hello everyone. I was wondering if someone could help me. As a debugging aid i want to see how many times my stored-proc is called and i also want to record certain variables. I would like to write this information to a text file on c:\ of the SQL Server. I am using MS Sql Server 2000.. Can anyone point me in the right direction please. Thanks
after some googling i have sorted my problem.. thanks
-
hello everyone. I was wondering if someone could help me. As a debugging aid i want to see how many times my stored-proc is called and i also want to record certain variables. I would like to write this information to a text file on c:\ of the SQL Server. I am using MS Sql Server 2000.. Can anyone point me in the right direction please. Thanks
here is a stored-proc which writes to a file
IF OBJECT_ID('dbo.sp_TestWriteToFile') IS NOT NULL DROP PROC dbo.sp_TestWriteToFile GO CREATE PROCEDURE [dbo].[sp_TestWriteToFile] AS exec master..xp_cmdshell 'echo hello > c:\file.txt' exec master..xp_cmdshell 'echo blah de blah > c:\file.txt', no_output GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO exec sp_TestWriteToFile
and here is one which appends data to a file:IF OBJECT_ID('dbo.sp_TestWriteToFile') IS NOT NULL DROP PROC dbo.sp_TestWriteToFile GO CREATE PROCEDURE [dbo].[sp_TestWriteToFile] AS exec master..xp_cmdshell 'echo appended data >> c:\file.txt' GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO exec sp_TestWriteToFile
-- modified at 11:40 Tuesday 31st October, 2006