When I go onto a client site, I usually don't have the luxury of designing everything from scratch. There are times (like on my current engagement) if I were given the choice, I'd say scrap it, but usually it doesn't happen that way. It is what it is... been saying that a lot lately!
So one of the tools I find useful is the ability to search for particular field names in the database. This is very similar to sp_findsp I use, which I have posted in the past off the net, but I have modified it so it gets registered as a system procedure.
So here's sp_findfields. It will return a fairly printable representation of the results of all fields which match the passed in string. It's registered as a system procedure in this script, so it is accessible to all databases.
Usage:
sp_findfields '%Contact%'
This will find all fields with the string 'Item' in it. Note you need to provide the wildcard characters.
USE masterGOIF (SELECT OBJECT_ID('sp_findfields','P')) IS NOT NULL BEGIN DROP PROCEDURE sp_findfields ENDGOCREATE PROCEDURE sp_findfields (@searchText varchar(50))ASBEGIN SELECT SchemaName = LEFT(TABLE_SCHEMA,10), TableName = LEFT(TABLE_NAME, 35), FieldName = LEFT(COLUMN_NAME, 40), DataType = LEFT(DATA_TYPE, 13), DataSize = CHARACTER_MAXIMUM_LENGTH, AlloysNulls = IS_NULLABLE FROM INFORMATION_SCHEMA.columns WHERE column_name like @searchText ORDER BY TableName, FieldNameENDGO--Mark procedure as system objectEXEC sys.sp_MS_marksystemobject sp_findfieldsGOGRANT EXEC ON sp_findfields TO publicGO
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail