This script demonstrates that how to execute the dynamic query in the MS Server 2005.
Declare @Query nvarchar(4000) SET @Query = 'Select GETDATE()' EXEC sp_executesql @Query
Output will be like ‘2010-07-16 17:42:38.733’
Note : datatype supported for dynamic query is “ntext/nchar/nvarchar”
EXEC sp_executesql is responsible to run the dynamic query.
Leave a Reply