在Ms Sql Server 2000中如何
判断一个数据表(T_TestTable)是否存在列名为abc?如果不存在则向表中插入列名为abc的列,数据类型为 float.
--判定是否存在T_TestTable
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_TestTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
--判定是否存在abc
if (NOT exists ( select * from dbo.syscolumns where name = 'abc' and id in (select id from dbo.sysobjects where id = object_id(N'[dbo].[T_TestTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)))
ALTER TABLE [dbo].[T_TestTable] ADD abc float
判断一个数据表(T_TestTable)是否存在列名为abc?如果不存在则向表中插入列名为abc的列,数据类型为 float.
--判定是否存在T_TestTable
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_TestTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
--判定是否存在abc
if (NOT exists ( select * from dbo.syscolumns where name = 'abc' and id in (select id from dbo.sysobjects where id = object_id(N'[dbo].[T_TestTable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)))
ALTER TABLE [dbo].[T_TestTable] ADD abc float