Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSQL How do you output PRINT in a user defined function?

Basically I want to use PRINT statement inside a user defined function to aide my debugging.

However I'm getting the following error;

Invalid use of side-effecting or time-dependent operator in 'PRINT' within a function.

Can this not be done?

Anyway to aid my user defined function debugging?

like image 734
c00ke Avatar asked Feb 25 '09 16:02

c00ke


People also ask

How do you print inside a function in SQL?

You can't use a print inside a FUNCTION. Try using a SELECT instead. And of course, the SELECT would have to 'fit' with the FUNCTION return datatypes.


1 Answers

Tip: generate error.

declare @Day int, @Config_Node varchar(50)      set @Config_Node = 'value to trace'      set @Day = @Config_Node 

You will get this message:

Conversion failed when converting the varchar value 'value to trace' to data type int.

like image 130
Estevez Avatar answered Sep 21 '22 12:09

Estevez