Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a requirement where I need to pull data from a database and my filter condition should be parameterized and should come from a text/excel file. So that business user can open that text/excel file and can change the condition accordingly.
For example:
My query is:
Select *
from dbo.Customer
where customerID in (22, 12)
and StateID in (100, 102, 125)
Now in above query how can I store these customerID values & StateID values in text/excel and this query calls those parameters from that file and then execute. In a way it will be dynamic so tomorrow user can go to this file and change the parameter value and without chaning any code the script will still work.
Best Regards,
Sachin
If your xls file has 2 rows and one column in wich you have:
Values
(22, 12)
(100, 102, 125)
you can
MyTable:
Load
Values
From myFileXls;
Let row1=Peek('Values',1,'MyTable');
Let row2=Peek('Values',2,'MyTable');
then your select will be
Select *
from dbo.Customer
where customerID in $(row1)
and StateID in $(row2)
hope it helps
If your xls file has 2 rows and one column in wich you have:
Values
(22, 12)
(100, 102, 125)
you can
MyTable:
Load
Values
From myFileXls;
Let row1=Peek('Values',1,'MyTable');
Let row2=Peek('Values',2,'MyTable');
then your select will be
Select *
from dbo.Customer
where customerID in $(row1)
and StateID in $(row2)
hope it helps
Thanks. It worked for me....