Link to home
Start Free TrialLog in
Avatar of schmir1
schmir1Flag for United States of America

asked on

Stored Procedure to search all tables and fields

I'm using SQL 2005 and I need a stored procedure to help me locate all tables and field names.  The procedures should do the following:
  Search all fields in the table for fields that begin with #
  Return the table name and all the field names beginning with #
  Do for each each table in the database
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Field NAMES that begin with # or field data that begins with #?

If the first:
select * from inforamtion_schema.columns
where column_name like '#%'
ASKER CERTIFIED SOLUTION
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of schmir1

ASKER

I should have said field data starting with #.  I'll check out the link
just change the line that does:

QUOTENAME('%' + @SearchStr + '%','''')

to

QUOTENAME(@SearchStr + '%','''')

That way you are looking for it at the beginning only.
"I should have said field data starting with #. "

It helps, but I gave you an answer in case it was either! :)
Avatar of schmir1

ASKER

Thanks for your help.  It worked great but returned 1/2 Million records.  Took a while to go through.
No doubt.  There is no EASY way to do that.