02-07-2022 05:43 AM
A statement like this works fine in SQL Server. How can I get something like this to work in the SQL Server - Execute Snap? There has to be a syntax issue that I have. Any help is appreciated.
DECLARE @sql AS varchar(max) = ‘This is a Test’
PRINT @sql
02-07-2022 06:15 AM
Hi @sdoscher,
If I understood you correctly, you want to return something from SQL Execute snap?
This syntax can help you “select ‘This is a Test’ as sql”. Put it in the SQL Execute Snap and see the results.
BR,
Marjan
02-08-2022 01:55 PM
Hi @marjan.karafiloski Yes, this works:
select ‘This is a Test’ as sql.
What I am ultimately trying to get to is for the Execute snap to execute dynamic SQL such as:
DECLARE @sql AS varchar(max)
SET @sql = ’
select top 10 * from dbname.dbo.hc_table
’
EXEC (@sql)
Can the Execute snap do that?
02-08-2022 11:20 PM
Hi @sdoscher ,
Yes, you can do that.
Here is an image of how to set the query in Execute Snap:
Here is an image of the output of the Execute Snap:
BR,
Marjan
02-09-2022 09:10 AM
Hmmm…that did not work for me. I talked to the SL admin and they said we are on
SQL Server snap pack main11181. That is not the latest version, would that have anything to do with it? What version are you on?