Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 selecting mutiple records from multiple tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-11-05 : 08:35:25
TejpartapS writes "hi,
this is tejpartap here.actually my problem is that i want to find all dates in userdefined tables are valid or not.

so what i am trying is fetching all the user tables from the server and their records but i am not able to do it.

can u send me a query which fetches all user tables in a database and their records.
i have seen your article (dynamic sql 1 and 2)but i m not able to follow.
so plz inform me with example.
thanks so much.
regards,
Tejpartap Singh."

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-05 : 08:44:11

Declare @tableList varchar(8000)
SELECT @tableList = COALESCE(@tableList + '; ', '') + 'exec(''select * from ' + table_name + ''')'
FROM INFORMATION_SCHEMA.tables
where table_type = 'BASE TABLE'
select @tableList

exec (@tableList)

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -