How can I tell if a column for a table already exists?

Neil Pike

November 28, 1999

1 Min Read
ITPro Today logo

A. There are two ways (with SQL 7) :-

IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '' AND COLUMN_NAME = '')

or

if columnproperty (object_id(''), '', 'AllowsNull') IS NOT NULL

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like