title: Conversion Failed String to Integer in SQL
body: <p>I have stored the OrganisationIds 1 ,2 in @String variables.i want to convert it into Integer.Can anyone please help?</p>
  
  <p>Below is my code..</p>
  
  <pre><code>DECLARE @RowCount INT
  Declare @String varchar(100)
  declare @OrganizationIds int
  SELECT @RowCount = COUNT(*) FROM @RawData
  WHILE (@RowCount&gt;0)
  BEGIN
         set @String=convert(varchar,@OrganizationIds)+','
           If (@RowCount&gt;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
  </code></pre>