DECLARE @Data binary(1024) SELECT @Data = Data FROM myTable WHERE Id=2is prefered over
DECLARE @Data binary(1024) SET @Data = (SELECT Data FROM myTable WHERE Id=2) <pre> ? After using an Id that exists I get the desired result using both approaches. :) Now to the part I don't understand. The SELECT statement with UNION ALL was that related to this post? Einar >Einar, > >The best way to do things in SQL Server is using set oriented approch. Something like <pre> >SELECT ID, Data FROM mytable WHERE id=2 >UNION ALL >... >To answer your question, try
> SELECT @Data = Data FROM myTable WHERE Id = 2 >>
>>DECLARE @rows int >>SET @rows = (SELECT COUNT(*) FROM Customers) >>>>@rows will now equal the number of records in the Customers table. That was easy, but that is not what I need.
>>Id Data >>--- ----- >>1 <binary> >>2 <binary> >>3 <binary> >>>>
>>DECLARE @Data binary(1024) >>SET @Data = (SELECT Data FROM myTable WHERE Id = 2) >>>>