cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Server - Execute Snap

sdoscher
New Contributor III

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

13 REPLIES 13

marjan_karafilo
Contributor

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

sdoscher
New Contributor III

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?

Hi @sdoscher ,
Yes, you can do that.

Here is an image of how to set the query in Execute Snap:
image

Here is an image of the output of the Execute Snap:
image

BR,
Marjan

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?