RIAS
asked on
SQL query with User input
Hi,
Is there a way to write sql query with user input.
Cheers
Is there a way to write sql query with user input.
Cheers
Can you give more details
ASKER
I need to save a sql query in database which first tries to execute before it saves in database.
There are some values in query which will be user input later.
Example query is :
select * from Personal_Details a
inner join DEATH_BENEFIT b on
a.REFNO=b.REFNO
inner join PENSIONER_DETAIL c on
c.REFNO=a.REFNO
inner join TRANSFER_OUT_HISTORY d on
d.REFNO=a.REFNO
where (a.CURRStatus in ('Active','PreservedPensio ner','Pens ioner','Wi dow','Chil d'))
or (a.CURRStatus = 'No Liability'
and ((a.Dateleft > dateadd(y,17/06/2011,-1)) or (b.dbdate > dateadd(y,17/06/2011,-1))
or (c.pdpencomm > dateadd(y,17/06/2011,-1)) or (d.topaid > dateadd(y,17/06/2011,-1))))
bold are the user input.
For the timebeing just need to replace it with user input.
Cheers
There are some values in query which will be user input later.
Example query is :
select * from Personal_Details a
inner join DEATH_BENEFIT b on
a.REFNO=b.REFNO
inner join PENSIONER_DETAIL c on
c.REFNO=a.REFNO
inner join TRANSFER_OUT_HISTORY d on
d.REFNO=a.REFNO
where (a.CURRStatus in ('Active','PreservedPensio
or (a.CURRStatus = 'No Liability'
and ((a.Dateleft > dateadd(y,17/06/2011,-1)) or (b.dbdate > dateadd(y,17/06/2011,-1))
or (c.pdpencomm > dateadd(y,17/06/2011,-1)) or (d.topaid > dateadd(y,17/06/2011,-1))))
bold are the user input.
For the timebeing just need to replace it with user input.
Cheers
Do you mean you want the person running the script (in Management Studio or wherever) to be prompted for parameters at runtime, or just want to know how to use variables?
ASKER
Hi,
Just want to know how to use variables.
Cheers
Just want to know how to use variables.
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers mate!!
ms sql management studio?
some home-grown app (which programming language)?
using a .sql file?
somehow else?