all groups > sql server mseq > may 2004 >
You're in the

sql server mseq

group:

Want to Know Colunm exist or not


Want to Know Colunm exist or not Ashish Patel
5/11/2004 9:41:03 PM
sql server mseq:
Dear Friend

I want to know that particular colunm is exist in table or not.
if not exist then i want to create it

Re: Want to Know Colunm exist or not Hugo Kornelis
5/12/2004 10:48:57 AM
[quoted text, click to view]

Hi Ashish,

I would check the documentation for the table to see if the columns
exists. If it does, fine. If not, I'd add the column and update the
documentation.

If you have no documentation, use sp_help MyTable to see how it is
currently defined, then create the documentation (the sp_help output
may be a good starting point).

Best, Hugo
--

Re: Want to Know Colunm exist or not Anith Sen
5/12/2004 11:51:10 AM
Look up the mata-data function COL_LENGTH in SQL Server Books Online. You
can do:

SELECT CASE WHEN COL_LENGTH ( 'tbl' , 'col' ) IS NULL
THEN 'Nope' ELSE 'Exists' END ;

You can also check the results of any of the COLUMNPROPERTY functions to see
if it is a NULL to check if the column exists in a table or not.

--
Anith

AddThis Social Bookmark Button