我已将OrganisationIds 1,2存储在@String变量中。我想将其转换为Integer.Can任何人都可以帮忙吗?
以下是我的代码..
DECLARE @RowCount INT
Declare @String varchar(100)
declare @OrganizationIds int
SELECT @RowCount = COUNT(*) FROM @RawData
WHILE (@RowCount>0)
BEGIN
set @String=convert(varchar,@OrganizationIds)+','
If (@RowCount>0)
Begin
PRINT 'Loop Sequence : ' + convert(varchar,@RowCount) + ' '
set @OrganizationIds = (SELECT OrgId FROM @RawData WHERE ROWID = @RowCount)
PRINT 'Orgid Inside Loop:' + Convert(varchar,@OrganizationIds)
End
Set @RowCount = @RowCount-1
Set @OrganizationIds = convert(varchar,@OrganizationIds)
PRINT 'Orgid Outside Loop:'+ convert(varchar,@OrganizationIds)
set @String=@String + Convert(varchar,@OrganizationIds)
END
PRINT 'String Value Outside Loop: ' + @String
Declare @TempData Table
(
OrganizationID int
)
insert into @TempData(OrganizationID)
EXEC GetFormsData_Organization @String
答案 0 :(得分:0)
我相信您必须使用CAST功能而不是转换。尝试解决问题。