Interesting Facts about execute command in SQL Server

Possible Error :

 Procedure expects parameter '@handle' of type 'int'.
Reason for this error:  From the error, you are able to predict that, the issue is due to the datatype. This issue may occur, if you are trying to execute a dynamic sql. 

Try to execute the sql with sp_executesql.
Two options of executing to your sql 

exec(@sql)  or exec sp_executesql @sql
I've succeeded the above issue and caught up the below issue now,

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

The reason is, I am trying to use the exec sp_execuesql method inside a function which is not accepted by SQL Server. Here is a fantastic guide for your apetite.

http://jimbojw.com/wiki/index.php?title=SQL_2005_-_Why_You_Can't_EXEC()_Inside_a_UDF


Cheers,
Venkatesan Prabu. J
Head, KaaShiv InfoTech,
http://www.kaashivinfotech.com/
Ebook Download
View all
Learn
View all