If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Checking all tables that have a specific column name?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 12:15
Breako Breako is offline
Registered User
 
Join Date: Jan 2006
Posts: 119
Checking all tables that have a specific column name?

Is there a command I can use to tell me all the tables in my schema that have a column name "Id"?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 12:42
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 13,587
Code:
SELECT TABLE_SCHEMA, TABLE_NAME
   FROM INFORMATION_SCHEMA.COLUMNS
   WHERE  'id' = COLUMN_NAME
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 13:59
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,322
Hmmmmm....why do you do it "backwards"?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #4 (permalink)  
Old 01-05-12, 15:20
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 13,587
I work regularly with langauges that get confused about assignment versus comparison. Only two of the languages I've ever dealt with allow you to assign a new value to a constant (in which case Wim would be sorely confused, because 2 very definitely CAN equal 3 there), and fortunately I don't have to work with either of those languages anymore.

Consider my coding style to be an idiocyncracy of an old phart. You should try to do it backwards sometime... It can be fun!

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #5 (permalink)  
Old 01-05-12, 15:54
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,292
Quote:
Originally Posted by Pat Phelan View Post
I work regularly with langauges that get confused about assignment versus comparison. Only two of the languages I've ever dealt with allow you to assign a new value to a constant (in which case Wim would be sorely confused, because 2 very definitely CAN equal 3 there), and fortunately I don't have to work with either of those languages anymore.
Have adjusted my Signature.

Quote:
Originally Posted by Pat Phelan View Post
Consider my coding style to be an idiocyncracy of an old phart. You should try to do it backwards sometime... It can be fun!
Backwards? You mean something like this?

Consider my phart to be an idiocyncracy of an old coding style.

"It can be fun!"
Guess I need to practice more.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #6 (permalink)  
Old 01-05-12, 16:28
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 13,587
No doubt about it Wim, that deserves yet another

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On