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

简单记录一下,不知道有没有其他的缺陷,反正暂时是可以运行的,如果有错,请指教,本人sql语句不怎么样。总感觉这语句不好。
修改已存在的列的列名:sp_rename 'T_INFO_TestTable.HouseNo','HouseNONew','column' ;
GO

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-12-31
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2021-11-18
  • 2022-12-23
  • 2022-02-02
  • 2021-11-04
  • 2022-02-02
相关资源
相似解决方案