如何使用sqlserver 2005编写将数据添加到表中的新列的sqlquery [英] how can I write the sqlquery for adding a new column to a table with data using sqlserver 2005
本文介绍了如何使用sqlserver 2005编写将数据添加到表中的新列的sqlquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何编写将带有数据的新列添加到表中的SQL查询.
解决方案
您不能添加具有不同数据的新列.您可以使用以下查询为该列插入默认值.
ALTER TABLE table_name ADD new_column数据类型 DEFAULT ' defautvalue' WITH VALUES
ALTER TABLE table_name ADD column_name数据类型
参考: http://msdn.microsoft.com/en-us/library/ms190273.aspx [ ^ ]
how to write the sql query for adding a new column with data to a table.
解决方案
You can not add a new column with different data. You can insert default value for that column using the below query.
ALTER TABLE table_name ADD new_column datatype DEFAULT 'defautvalue' WITH VALUES
ALTER TABLE table_name ADD column_name datatype
Ref:http://msdn.microsoft.com/en-us/library/ms190273.aspx[^]
这篇关于如何使用sqlserver 2005编写将数据添加到表中的新列的sqlquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文