Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How do I set a variable equal to the results of a SQL query?
for example let x = select dbname from table
You can do it otherway, store the sql query output in table and after that, using peek function you can assign it to any variable.
SQLTableList:
LOAD Name as TableNames;
SELECT Name From AdventureWorksDW2008R2.sys.tables;
let vMyTableName = Peek('TableNames',0,'SQLTableList');
Hope this helps.
You can do it otherway, store the sql query output in table and after that, using peek function you can assign it to any variable.
SQLTableList:
LOAD Name as TableNames;
SELECT Name From AdventureWorksDW2008R2.sys.tables;
let vMyTableName = Peek('TableNames',0,'SQLTableList');
Hope this helps.