SQL Functions - Logging
debugging, function, sql-server-2008
Solution
try:
DECLARE @ExecuteString varchar(500)
,@Yourtext varchar(500)
@ExecuteString = 'echo '+@Yourtext+' > yourfile.txt)
exec master..xp_cmdshell @ExecuteString, no_output
use: ">" to create/overwrite file, and ">>" to create/append onto file. you might need to use `REPLACE(@Yourtext,'&','^&')` to escape the `&` char
Problem
Possible Duplicate: TSQL How do you output PRINT in a user defined function? This is driving me crazy. I have a function I am trying to debug, but I can't insert into a table, execute a print statement, or even raise an error from it. SQL returns the message Invalid use of a side-effecting operator 'PRINT' within a function. How can I Debug this, I just want to know the value of a variable while it is running?