Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple record in select query.

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2011-07-02 : 05:00:39
Dear All,

I am using following query, if i am running only select query then i am getting two records, but when i am declaring variable and trying to pass the select query data i am getting only single record.

Can anybody help me how to take both record coz i want to use this query as a sub query with IN clause ?

DECLARE @RateSheetId VARCHAR(100);
SELECT @RateSheetId = Rate_Sheet_ID
FROM tb_lcr_rate_deck_detail RD (nolock)
INNER JOIN tb_lcr_rate_deck_carrier_rate_sheet RDRSH (nolock)
on RDRSH.Rate_Deck_Details_ID=RD.ID
WHERE RD.ID='87D66BDA-BA3B-4E4B-8594-FE5411572D7A'
print @RateSheetId

Thanks and Regard's
Harish

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-02 : 06:55:19
You mean you are only getting the variable set to one of the values?
It can only hold a single value.

If yu mean that if you set the variable to '87D66BDA-BA3B-4E4B-8594-FE5411572D7A'
and

DECLARE @RateSheetId VARCHAR(100) = '87D66BDA-BA3B-4E4B-8594-FE5411572D7A';
SELECT *
FROM tb_lcr_rate_deck_detail RD (nolock)
INNER JOIN tb_lcr_rate_deck_carrier_rate_sheet RDRSH (nolock)
on RDRSH.Rate_Deck_Details_ID=RD.ID
WHERE RD.ID=@RateSheetId

then check the values in the table and there datatypes.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-07-02 : 07:39:52
Why do you think you need a variable?
You can use that statement together with your next query.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2011-07-02 : 07:49:02
thnks.
Go to Top of Page
   

- Advertisement -