Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Make a list of all tables in all data bases with creation date


Make a list of all tables in all data bases with creation date

Author
Message
kamel Gazzah
kamel Gazzah
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 7
Comments posted to this topic are about the item Make a list of all tables in all data bases with creation date
thadeushuck
thadeushuck
SSC-Enthusiastic
SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)SSC-Enthusiastic (179 reputation)

Group: General Forum Members
Points: 179 Visits: 164
DECLARE @db_name sysname, @SQL nvarchar(max)
--
IF OBJECT_ID('tempdb..#Results') IS NOT NULL
DROP TABLE #Results;
IF OBJECT_ID('tempdb..#Databases') IS NOT NULL
DROP TABLE #Databases;
--
CREATE TABLE #Results (DatabaseName sysname, TableName NVARCHAR(128), crdate datetime);
CREATE TABLE #Databases (databaseName sysname);
--
INSERT INTO #Databases
SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'msdb', 'model');
WHILE (SELECT COUNT(*) FROM #Databases) > 0
BEGIN
SET @db_name = (SELECT TOP 1 databaseName FROM #Databases);
SET @SQL = 'USE ['+@db_name+'];
INSERT INTO #Results Select '''+@db_name+''' as [dbname], name as [tblname], crdate from sysobjects'
--
EXEC (@SQL)
--
DELETE #Databases
WHERE databaseName = @db_name
END;
--
SELECT * from #Results;


just another cursor rewrite for fun..
Dave Vroman
Dave Vroman
SSC-Enthusiastic
SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)SSC-Enthusiastic (181 reputation)

Group: General Forum Members
Points: 181 Visits: 722
Change the statement
DECLARE c CURSOR  FOR


to
DECLARE c CURSOR LOCAL FAST_FORWARD READ_ONLY FOR


and test the speed difference.
Mahmood.BilalB
Mahmood.BilalB
Right there with Babe
Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)Right there with Babe (787 reputation)

Group: General Forum Members
Points: 787 Visits: 163
I have tested the code and it is giving an error. I think end statement is not required at the last line, just comment that out and it works
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10362 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search