Did you read Viaskh's post?When you do aSELECT @variable = [col]FROM x
What actually happens is that @variable gets assigned the values in the col one after another until the last (ordered in no guaranteed way) row. The variable will then hold the value of one of the rows in the column.I think you should post what you want to accomplish in the end. I doubt that your code is doing as you want it to.Visakh suggested you could do something like this.DECLARE @rpi TABLE ( [report_group_identifier] VARCHAR(255) )INSERT @rpiSELECT fgr.report_group_identifierFROM fee_grouping_report_v fgr (NOLOCK)WHERE fgr.tran_type in (462)--,463) AND fgr.report_id in (100,148)SELECT * FROM @rpi
Post some sample data and explain what you need to generate from it.Regards,