我试图用RAISERROR(Cast (select @HostelId as varchar(50))
Raiserror显示我的变量。但是我不知道如何将sql变量转换为字符串。
Declare @HostelId int=0;
Declare @Hostels Cursor;
SET @Hostels = cursor for select Hostel.HostelCode
From Hostel
Open @Hostels
While @@FETCH_STATUS = 0
Fetch next from @Hostels into @HostelId
Begin
RAISERROR(Cast (select @HostelId as varchar(50)), 0,0);
End
Close @Hostels
对消息字符串参数使用格式字符串,如下所示:
RAISERROR('%d', 0,0, @HostelId);
Open @Hostels
Fetch next from @Hostels into @HostelId
While @@FETCH_STATUS = 0
Begin
RAISERROR('%d', 0,0, @HostelId);
Fetch next from @Hostels into @HostelId
End
Close @Hostels
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句