I want to write a query that looks something like this. I get an error
running this:
select id_1 =
case [ID]
WHEN 1 then 'test' , 'test2' -- error
end
from myTable where id = 1
That way, I don't have to run the same query twice. I'll then insert those
two values in another table.
Thanks.use two case functions, one for each column
select id_1 = case [ID]
WHEN 1 then 'test'
end
,select id_2 = case [ID]
WHEN 1 then 'test2'
end
from myTable where id = 1
"VMI" <VMI@.discussions.microsoft.com> wrote in message
news:9226AEED-DE32-4555-803F-356992ED22D8@.microsoft.com...
> I want to write a query that looks something like this. I get an error
> running this:
> select id_1 =
> case [ID]
> WHEN 1 then 'test' , 'test2' -- error
> end
> from myTable where id = 1
> That way, I don't have to run the same query twice. I'll then insert those
> two values in another table.
> Thanks.|||Can you give the actual requirement?
For your query, the case statement is redundant.
"VMI" wrote:
> I want to write a query that looks something like this. I get an error
> running this:
> select id_1 =
> case [ID]
> WHEN 1 then 'test' , 'test2' -- error
> end
> from myTable where id = 1
> That way, I don't have to run the same query twice. I'll then insert those
> two values in another table.
> Thanks.
No comments:
Post a Comment