|
|
Question : Server: Msg 137, Level 15, State 2, Line 9: Must declare the variable '@vriable'.
|
|
Isnt it declared? ================== declare @aid numeric(9), @table_name varchar(100), @view_name varchar(100), @string_execute varchar(1000), @TIN varchar(9) declare c cursor for select aid, table_name, view_name from vwagency_tables set @TIN = '571008538' open c declare @tincount int fetch next from c into @aid,@table_name,@view_name -- <---- Declared here?, yes? while @@fetch_status = 0 begin If not exists(select TIN from @view_name where TIN=@TIN) --No worky --SELECT @tincount = COUNT(TIN) FROM @view_name WHERE TIN=@TIN - No worky --set @string_execute = 'select TIN from ' + @view_name + ' where TIN='+@TIN | - Works fine --exec (@string_execute) | - Works fine fetch next from c into @aid,@table_name,@view_name end close c deallocate c --------------------- Server: Msg 137, Level 15, State 2, Line 9 Must declare the variable '@view_name'.
|
Answer : Server: Msg 137, Level 15, State 2, Line 9: Must declare the variable '@vriable'.
|
|
|
|
|
|
|