- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Utilizing a variable in a string to query SQL Server
I am looking to utilize an input parameter to query SQL Server. Having a little difficulty doing the following:
If I were utilizing SQL:
Select *
FROM Test
WHERE samplecolumn = ('concat_' + @Variable)
Trying in Qlikview:
select *
from Test
Where samplecolumn = ('concat_' $vVariable)
Getting an error because of the quotes being around the "Concat," but when trying to add around the variable, it is not considered.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Figured it out.
where samplecolumn = 'Concat_$(vVariable)'
Thank you all for your assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure what you want, can you give more details. If you trying in Qlikview then hope below code helps:
select *
from Test
Where samplecolumn = '$(vVariable)'- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about this
Load *
from Test
Where samplecolumn = ('concat_' & $(vVariable))
What Ares trying to achieve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to utilize a variable to complete a string to query on a where statement.
If I were utilizing SQL Server, the query would look like:
declare @Variable as nvarchar(4) = '9999';
Select *
FROM Test
WHERE samplecolumn = ('concat_' + @Variable)
The result would then be:
concat_9999
However, in qlikview, if I declare the variable, vVariable, it is giving me an error.
select *
from Test
Where samplecolumn = ('concat_' $vVariable)
I need Qlikview to take the variable, 9999, and concat for the where statement look like this:
where samplecolumn = 'concat_9999'
The result I am currently getting is:
where samplecolumn = 'concat_' 9999
Which is incorrect syntax for SQL Server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Figured it out.
where samplecolumn = 'Concat_$(vVariable)'
Thank you all for your assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create vVariable in the Variable Overview as 9999
Load *
From Test
Where Samplecolumn='concat_' &'$(vVariable)';
There are also couple of ways:
Option I:
LET vVariable= 9999;
LOAD
*
Where Samplecolumn='concat_' &'$(vVariable)';
SQL SELECT *
FROM mydb.dbo.reps;
Option II
LET vVariable= 9999;
LOAD
*
;
SQL SELECT *
FROM mydb.dbo.reps
Where Samplecolumn='concat_' &'$(vVariable)';
Replace "mydb.dbo.reps" with your database and table. Hope this helps...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might need to include the variable inside of the quotes.
Try it this way and see if it fixes the issue. It is working correctly on my machine:
SELECT *
FROM Test
Where Samplecolumn = 'concat_$(vVariable)';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sounds good, close this thread to put the flag Correct Answer.