February 24, 2020 at 4:46 am
DB Script for getting database name which contains one table in common?
Regards,
Ram
February 24, 2020 at 12:52 pm
Can you clarify a little what you're looking for here please?
Do you want to compare all the tables in all the databases on a server and find a list of databases where there are any objects in common? Is that it? Or something else?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 24, 2020 at 3:10 pm
Do a search for "ms for each db sql server" and follow your nose to write some custom code.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 24, 2020 at 3:35 pm
Is that a statement, or a question? It reads like a statement, but ends in a question mark.
What are you actually after here? Are you looking for table names that appear in every database? Are you looking for specific tables that don't appear in specific databases (which means that they need to be added)?
Either of these, however, infer a design flaw; normally duplicating the same objects through your databases means you have normalisation issues, and are trying to use databases to denote information that likely should be stored in a column.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
March 2, 2020 at 5:36 am
we are looking for a list of databases where there is one objects in common, Is there DB script ?
Thanks
March 2, 2020 at 5:37 am
Sorry Thom, It was a question not statment
March 2, 2020 at 8:04 am
Can you define the commonality conditions.
DB1 has a table called "Orders" with "28 columns" in the "DBO schema"
DB2 has a tabled called "Orders" with "69 columns" in the "SALES schema"
Is the commonality the name, or also in the definition, or also in the schema?
March 2, 2020 at 8:30 am
we are looking for a list of databases where there is one objects in common, Is there DB script ?
Thanks
So any object in common or a specific object in common? We'd all like to help, but we're still very unclear on what you're looking for.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
March 2, 2020 at 8:58 am
Table Orders Schema,Definition are same. but row may differ.
March 2, 2020 at 9:00 am
one specific object common.
We have Object A which is common in some database, will have to retrieve the current row of Object A in all databases and insert the new row on that Object A across databases.
March 2, 2020 at 7:42 pm
March 3, 2020 at 9:15 am
Table Orders Schema,Definition are same. but row may differ.
You're still not giving any clarity I'm afraid. Perhaps show us what you're after, as your descriptions are very vague; they might help us understand.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
March 3, 2020 at 9:35 am
one specific object common.
We have Object A which is common in some database, will have to retrieve the current row of Object A in all databases and insert the new row on that Object A across databases.
So, if I understand, the plan is, compare a single table's schema definition across multiple databases to identify any that are different. Is that right?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
March 3, 2020 at 2:19 pm
It sounds to me like you have an identically named/structured table in multiple databases and they want to keep all of them in sync insofar as content. Is that correct?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 5, 2020 at 5:24 pm
Run:
EXEC sp_msforeachdb
'USE [?];
SELECT
TABLE_SCHEMA,
TABLE_NAME,
DB_NAME() AS "DATABASE_NAME"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'Base Table';';
against every database in SSMS, copy/paste results to Excel and sort by TABLE_NAME, DATABASE_NAME.
Joie Andrew
"Since 1982"
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply