tlkerns wrote:
Something like this:
A much better way to implement this IMO is:
\\\
if not exists(
select *
from INFORMATION_SCHEMA.tables
where TABLE_NAME = 'MyTable')
begin
create table ...
end
///
This is using a well-documented ANSI/ISO standard view to retrieve data on
the schema rather than hacking around in system tables and using "magic"
values. Works in SQL Server 2000 and later (and in many non-SQL Server DBMSs
too).
I continue to be very surprised to see how many people turn to system tables
to retrieve schema data when these views have been around for years and
provide all the same data in a much more easily obtainable and future-proof
fashion.
--
(O)enone