ChrisM@Work (5/7/2013)
Which column of the VALUES clause of the INSERT statement is it?'V'+@retval + Replace( Str( @max-2 + @count, 7), ' ', '0') ?
seems likely, but you have no column list to insert into.
Yes I have not provided column list while inserting as I am inserting in all columns of a table...
and i think error is coming becouse as per your script @retval is not initilazed and it is using in @max-2 value assign.
SELECT @max-2 = ISNULL(vouchervalue,0) FROM gv_vouchervalue WHERE voucherabbreviation = 'V'+@retval
Also can you please tell me that I assgin values to variables using SET but changed them to SELECT... Is there any difference between them?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/