Query which table has a field

Source: Internet
Author: User

Today, a netizen asked me, he knows the field name, but want to know which tables have these fields, so that he convenient work, think about, wrote a stored procedure for him, I think there may be a netizen encountered this situation, so put it out for everyone reference.

1 Create procUsp_colum_search2 @column_name varchar( -)--Field name3 4  as5 /*6 LCL7 Date: 2015-07-148 call: Exec usp_colum_search ' KSDM '9 Description: Queries which tables have the columnTen */ One  A  - --declaring Cursors - DeclareSearch_curcursor  for SelectId fromsyscolumnswhereName=@column_name the --declaring Variables - Declare @id int -  - --Open Cursor + OpenSearch_cur -  + --Start Moving A FetchSearch_cur into @id at --Start Loop -  while(@ @FETCH_STATUS=0) - begin - Select object_name(@id) asTable name - FetchSearch_cur into @id - End in  - --Close Cursors to CloseSearch_cur + deallocateSearch_cur

Query which table has a field

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.