如何在SQL Server表中添加列 [英] How to add column in SQL server table

查看:129
本文介绍了如何在SQL Server表中添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c#上通过Windows应用程序在sql server 2005中添加列.列名称是从Windows窗体的文本框中获取的.当我单击Submit按钮时,应在sql表中创建一个新列.子查询将在该列中插入一个值.我想要所有此过程的代码,请帮帮我或指导我怎么做..提供C#中的整个代码
谢谢alot

How to add columns in sql server 2005 from windows application made on c#. And the columns name is taken from textbox in my windows form.When i click submit button it should make a new column in sql table.and a sub query will insert a value in that column. I want the code of all this procedure please help me out or guide me how o do this thing..supply with the whole code in C#
Thanx alot

推荐答案

您需要使用Alter命令来执行此操作.参见
http://www.w3schools.com/sql/sql_alter.asp [ [
You need to use Alter command to do this. See
http://www.w3schools.com/sql/sql_alter.asp[^].

This[^] might give you some ideas as well.


我认为这也对您有所帮助.从您的应用程序中调用它.
I think this helps you too.Call it from your application...
ALTER TABLE <table_name>
(
  ADD <column name=""> <optional constraint>
  [, ... ]
)


我认为您可以轻松地在表中添加列
您执行以下命令

ALTER TABLE< TABLE_NAME>添加< COLUMN_NAME> < DATA_TYPE> < CONSTRAINT>

例子
ALTER TABLE EMP添加薪水int
I think you can easily add column in your Table
you execute following command

ALTER TABLE <TABLE_NAME> ADD <COLUMN_NAME> <DATA_TYPE> <CONSTRAINT>

example
ALTER TABLE EMP ADD SALARY int


这篇关于如何在SQL Server表中添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆