December 2, 2010 at 2:51 pm
I have this query - problem is my results bring back hundreds of tables..
I need to know if the tables it returns have records in them (most do not) So, I can update just the tables that have data.
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%tin%'
ORDER BY schema_name, table_name;
How can I add that to the above statement?
December 2, 2010 at 3:01 pm
join to sysindexes on indexID IN ( 0, 1) and check the row column.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
December 2, 2010 at 3:08 pm
.. can anyone help me with the syntax?
December 3, 2010 at 10:59 am
Sorry, got distracted:
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
JOIN sysindexes AS i ON i.id = t.object_id
WHERE c.name LIKE '%n%'
AND i.indid IN ( 0, 1)
AND i.rowcnt > 0
ORDER BY schema_name, table_name;
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
December 6, 2010 at 7:51 am
lol...awesome thanks craig!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply