Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for existence of column in table

Status
Not open for further replies.

nodoubtom

Programmer
Oct 15, 2007
8
US
How do I check for the existence of a column in a table for SQL Server 2005.

Thanks!
 
select * from information_schema.columns
where column_name = 'what ever'
and table_name = 'yourTable'

- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Thanks for your quick response. When I run this without the WHERE it's not pulling back all columns that I know are in the table. Why would this be?

Thanks!
 
Sorry. I was in the wrong DB. That's why it wasn't finding it! Thanks for your help!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top