add column for a table if this column not exists using T-SQL in SQLServer
2009-04-28 10:11
489 查看
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'LandlordInfo' AND COLUMN_NAME = 'IsSigned')
BEGIN
ALTER TABLE LandlordInfo ADD IsSigned bit null
END
WHERE TABLE_NAME = 'LandlordInfo' AND COLUMN_NAME = 'IsSigned')
BEGIN
ALTER TABLE LandlordInfo ADD IsSigned bit null
END
相关文章推荐
- Check if a database or table exists using Sql Server 2005
- SqlServer IF Exists([database]|[table]|[prop]) / Column([Operation])
- “DROP TABLE IF EXISTS” in Oracle and SQL Server
- Mysql官方文档中争对安全添加列的处理方法。Mysql Add a Column to a table if not exists
- DROP TABLE IF EXISTS” in Oracle and SQL Server
- DROP TABLE IF EXISTS” in Oracle and SQL Server
- SQL Server error "Xml data type is not supported in distributed queries" and workaround for it
- sql server query to get the list of column name in a table
- Using INSTEAD OF triggers in SQL Server for DML operations
- Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
- Using NOLOCK and READPAST table hints in SQL Server
- 使用cocapods报错 [!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes
- Mysql官方文档中争对安全添加列的处理方法。Mysql Add a Column to a table if not exists
- Using the INSERTED table in SQL Server 2000
- To SP or not to SP in SQL Server: an argument for stored procedures
- SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by
- This article provides a fix for the error: Login failed for user “. The user is not associated with a trusted SQL Server
- Could not store transport type data for Receive Location 'Recv.Loc' to config store. Primary SSO Server 'Sql-server' failed. The external credentials in the SSO database are more recent.
- Using INSTEAD OF triggers in SQL Server for DML operations
- using sql server or sql azure for session state store in asp.net