Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Use variable as table Name in SQL

$
0
0
is it possible to create a temp table and iterate through each database in the temp table? Something like and this would iterate both tables in the databse and display the results. (Of course I would actually be doing this on a much larger scale and not just selecting *
Code:

Declare @CountCheck int

Create table #databse
(
Name varchar(100),
Verified varchar(100)
)
Insert into #databse
Values('Foxtrot')
Insert into #databse
Values('Charlie')

while Verified IS NULL

begin
Select * from Name

update #databse set Verified = 'Yes'

end


Viewing all articles
Browse latest Browse all 13329

Trending Articles