Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Terra
Contributor II
Contributor II

Can you use SQL variables in Load

Are you able to load SQL queries with variables/table variables? I would like to keep the TSQL syntax for the variables. The below query is just an example and is not practical. 

Example:

DECLARE
@fdate DATETIME,
@tdate DATETIME,

SET @fdate = '1/1/2021'
SET @tdate = '1/31/2021'

DECLARE @test TABLE(
ID INT
)

INSERT INTO @test

SELECT ID FROM table1

WHERE ID < 50

 

SELECT *

FROM table2 t2

JOIN @test t1 ON t2.ID = t1.ID 

 

 

Labels (1)
  • TSQL

2 Replies
MayilVahanan

Hi Terra,

you can create sp in ur SQL server & use it in qlik app

SQL EXEC urprocedurename;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Terra
Contributor II
Contributor II
Author

Thank you. Yes I thought of that as well, however I don't want to create Sprocs every time I have a script that is similar to this.