Friday, February 24, 2012

checking the existance of fields and types

I'm trying to write a program in cold fusion to check the existance of
fields and data types according to requirements

I was looking at the syscolumns table for some of this information but
I've discovered that in my playing (creating and deleting tables) thre
are multiple entries for a field that is in table that is created then
deleted then created again.

Is this a problem? Is there a better way to get at the information ie
the table, field, and type exist in a database?Use the INFORMATION_SCHEMA views. See Books Online for details.

Most metadata can be retrieved more easily from the info schema than
from system tables. There are some exceptions but system tables are
best left alone unless you really have to use them. They will be
supported only for backwards compatibility and won't reflect new
features in future versions.

--
David Portas
SQL Server MVP
--|||William Kossack (kossackw@.njc.org) writes:
> I'm trying to write a program in cold fusion to check the existance of
> fields and data types according to requirements
> I was looking at the syscolumns table for some of this information but
> I've discovered that in my playing (creating and deleting tables) thre
> are multiple entries for a field that is in table that is created then
> deleted then created again.

This sounds very strange. My guess is that you are joining syscolumns
with systypes incorrectly. (Those two tables are indeed a bit tricky
to match up.) Care to post a query that gives funny result?

> Is this a problem? Is there a better way to get at the information ie
> the table, field, and type exist in a database?

Some people tout the INFORMATION_SCHEMA views, but since they only
give a subset of the metadata information, they're pretty useless in
my opinion. They are mainly interesting if you want to write portable
meta-data queries.

There are also functions like object_id, columnproperty which can be
useful at times, but they have the drawback that they are restricted
to the current database.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment