on 08-22-2017 8:45 AM
Good Morning SAP Experts,
i really have a very important Issue ( to me ) and i tried every possible way to solve it but still have no result.
select t.a , t.b , t.c from myTable where t.d = [%0]
this is going to work very well and the user has to input the value of "d".
why doesnt it work like this :
declare @aa varchar(20)
SET @aa = [%0]
select t.a , t.b , t.c from myTable where t.d = @aa
??
my problem is simply that i need sometimes to use this input in two different positions in the same Qurey.
i need to let the user input the value that i store as a variable and use this variable wherever i need it in my Query... as simple as this.
Can anyone help me or make me understand why it doesnt work like this?
Thanks in Advance
Hi ,
Use Below logic:-
declare @aa varchar(20)
SET @aa = (select x.d from mytable x where x.d = [%0])
select t.a , t.b , t.c from myTable t where t.d = @aa
from this way you can use @aa variable more than one time.
Regards,
Anand
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.