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


Find Column Name Usage


Find Column Name Usage

Author
Message
kgayda
kgayda
SSC Veteran
SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)

Group: General Forum Members
Points: 277 Visits: 172
Comments posted to this topic are about the item Find Column Name Usage


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
Andrew_Webster
Andrew_Webster
SSC-Enthusiastic
SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)

Group: General Forum Members
Points: 128 Visits: 32
Try this for a trick: use Excel/MS Query to open INFORMATION_SCHEMA.COLUMNS then use Autofilter to create a simple data dictionary tool that does something very similar to your script.



kgayda
kgayda
SSC Veteran
SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)SSC Veteran (277 reputation)

Group: General Forum Members
Points: 277 Visits: 172
Thanks for the tip!


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
Arnie Stewart
Arnie Stewart
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: 43
I found this very useful. I am constantly looking for a particular element name.
I took some liberties and enhanced my version of the code to look across all database on the server; using a cursor to store db names.
My code enhancement is shown below.

Arnie Stewart


DECLARE @DB AS VARCHAR(25)
DECLARE @CNT AS INT
DECLARE @SQL NVARCHAR(4000)
DECLARE @vcColumnName varchar(100)
--
--
SET @vcColumnName = 'PAT_NM'
--
--
DECLARE C1_CURSOR SCROLL CURSOR FOR
SELECT NAME AS DB
FROM MASTER.dbo.sysdatabases
WHERE NAME NOT LIKE 'MASTER' AND
NAME NOT LIKE 'TEMPDB' AND
NAME NOT LIKE 'MODEL' AND
NAME NOT LIKE 'MSDB'
ORDER BY
NAME

TRUNCATE TABLE ADHOC.DBO.TBL_IT_COLUMNS_DBASE_LOOKUP

SET @CNT = 0
OPEN C1_CURSOR
FETCH NEXT
FROM C1_CURSOR
INTO @DB
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL='INSERT INTO ADHOC.DBO.TBL_IT_COLUMNS_DBASE_LOOKUP
SELECT DISTINCT ''' + @DB + '''AS DBASE, SUBSTRING(o.NAME,1,60) AS [Table Name]
FROM ' +@DB+'.dbo.sysobjects o
INNER JOIN ' +@DB+'.dbo.syscolumns c
ON o.ID = c.ID
WHERE c.name = ''' + @vcColumnName + '''
AND o.XTYPE = ''U''
ORDER BY [Table Name]'
EXEC(@SQL)

FETCH NEXT FROM C1_CURSOR INTO @DB
END
CLOSE C1_CURSOR
DEALLOCATE C1_CURSOR

SELECT * FROM ADHOC.DBO.TBL_IT_COLUMNS_DBASE_LOOKUP
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