>How can I assign a value to a @local_variable, when the value is a field value from a SELECT statement?
>I am not sure if my question makes sense (even to me<s>), so I will try to explain it further.
>
>Considder the following:
>
>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.
>
>Assume I have the following table called myTable:
>
>Id Data
>
>1 <binary>
>2 <binary>
>3 <binary>
>
>
>I want to store the binary data that is stored in the data column in row where Id = 2. What would the code look like?
>
>
>DECLARE @Data binary(1024)
>SET @Data = (SELECT Data FROM myTable WHERE Id = 2)
>
>
>But the code above does not work the way I expect it to.
>I hope I have explained my problem well enough. Please let me know if it is still unclear.
>
>Thanks,
>Einar
The code above works just fine. It helps if I use an Id in the where clause that acctually exists! Duhh!!
Is there a better way of doing what I want to do?
Einar
Semper ubi sub ubi.