March 12, 2013 at 7:14 am
Hi,
I have a below query-->
declare @Rid bigint
set @Rid =106,108;
UPDATE Cust
SET Cust.IsVal= 1
FROM Cust
INNER JOIN CustRid
ON Cust.PlRid= CustRid.Id
WHERE Cust.PId IN (@Rid)
Here my Cust.PId is Bigint type and it will not allow me to pass values.
How I pass @Rid to IN Clause when my Cust.PId is Bigint.
Please suggest any approach!!!
March 12, 2013 at 7:51 am
This
declare @Rid bigint
set @Rid =106,108;
generates an error, because bigint datatype holds a single bigint, not a list of them. If @Rid was a character type then you would be able to construct what looks like a list, like this:
declare @Rid VARCHAR(100)
set @Rid = '106,108';
But it isn't, it's a single value. The list for an IN looks like this:
IN (106,108) for BIGINT
IN ('106','108') for character type
There are numerous ways of dealing with this issue. Where does @Rid get populated? Is it, say, a parameter passed into a stored procedure? If so, you could split out the elements of the string into a proper table.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply