SQLSERVER で カーソルを使用して2つのテーブルを比較し、比較した結果をCSVに出力したいです。
print @kekka の部分をcsvとして、ということは可能なのでしょうか?
declare @A_name as nchar(10), @A_weight as int, @B_name as nchar(10), @B_weight as int, @kekka as nvarchar(max)=''; declare cursor_A cursor for select A_name,A_weight from A_TABLE open cursor_A fetch next from cursor_A into @A_name,@A_weight while @@fetch_status=0 begin declare cursor_B cursor for select B_name,B_weight from B_TABEL open cursor_B fetch next from cursor_B into @B_name,@B_weight while @@fetch_status=0 begin if @A_name = @B_name and @A_weight <> @B_weight set @kekka =@kekka + @A_name + ',' + @A_weight + CHAR(13); fetch next from cursor_B into @B_name,@B_weight end close cursor_B deallocate cursor_B fetch next from cursor_A into @A_name,@A_weight end close cursor_A deallocate cursor_A print @kekka
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/10 09:08
2018/02/10 09:43
2018/02/11 08:56
2018/02/12 00:47