2017-03-14 7 views

答えて

0
DECLARE @animals TABLE (
id int identity(1,1),--identity is optional if your select returns an id 
name varchar(50) 
); 

insert into @animals 
--Your Select statement here 

Declare @string varchar(1000); 

select @string = ISNULL(@string + ', ', '') + animals.animal_name 
from 
(
Select id, name from @animals 
) animals (id, animal_name) 
+1

はいこの作品はありがとうございます:) –

0
declare @my_string varchar(1000) 

select @my_string = ISNULL(@my_string + ', ', '') + animals.animal_name 
from 
(
    values 
    (1, 'dog'), 
    (2, 'cat'), 
    (3, 'mouse') 
) animals (id, animal_name) 

select @my_string 

enter image description here

0

正確にはわかりませんが、テーブル変数を使用できますか?

DECLARE @animals TABLE (
    animal varchar(50) 
    ); 

と値を挿入します。

関連する問題