emi_sastra
asked on
SQL Variable Problem
Hi All,
I have below script :
The result :
What is wrong with @Positions ?
Thank you.
I have below script :
DECLARE @POSITIONS VARCHAR(100) = '''SLF'', ''SRF'''
select @POSITIONS as POSITIONS
SELECT
A.PositionCode
FROM TMPOSITION A
WHERE A.PositionCode IN ('SLF', 'SRF')
SELECT
A.PositionCode
FROM TMPOSITION A
WHERE A.PositionCode IN (@POSITIONS)
The result :
POSITIONS
----------------------------------------------------------------------------------------------------
'SLF', 'SRF'
(1 row(s) affected)
PositionCode
------------
SLF
SRF
(2 row(s) affected)
PositionCode
------------
(0 row(s) affected)
What is wrong with @Positions ?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Eric,
Using RTRIM works.
Thank you very much for your help.
Using RTRIM works.
Thank you very much for your help.
ASKER
Hi Stefan and Eric,
Thank you very much for your help.
Thank you very much for your help.
ASKER
It does not work with your code.
Open in new window
Thank you.