Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lose scope who to pass
Message
From
30/04/2002 13:01:31
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00648410
Message ID:
00650962
Views:
22
Hi!

I tried your code with the folowing changes, by eliminating the exec call:

declare @c1 varchar(500), @cnt int , @tbl varchar(300)
set @cnt = 1
set @tbl = !! did not see where you set this so I set it here

while @cnt <> 0 -- Reset to 0 when good!
begin

exec('Use '+ @db)

if exists (select * from syscolumns where name = @fld and id =
( select id from dbo.sysobjects where id = object_id(@tbl)
and OBJECTPROPERTY(id, 'IsUserTable') = 1 )
)
begin
set @cnt = @cnt+1
Set @fld = @fld+'_'+cast(@cnt as varchar)
print @fld
end
else
begin
set @cnt = 0
print 'Field Does Not Exist'
end

end

Hope it helps!
Ramona
Previous
Reply
Map
View

Click here to load this message in the networking platform