Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Alter Column

Author  Topic 

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-01-17 : 06:41:12

Is it possible to add, change, modify and drop one more column in a single query.

I tried,

ALTER TABLE Table_Name ADD Col1 DataType, Col2 DataType
Its added two columns

Likewise i change, modify and drop one more columns in a single query

I tried, It shows error So is this possible or not.

ALTER TABLE Table_Name CHANGE Old_Col1 New_Col1 DataType, Old_Col2 New_Col2 DataType

ALTER TABLE Table_Name CHANGE (Old_Col1 New_Col1 DataType, Old_Col2 New_Col2 DataType)

Both shows errors
Similarly to modify and drop also.

Kindly reply




When you realize you've made a mistake, take immediate steps to correct it.

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-01-17 : 06:54:19
It is not possible to alter multiple columns in a single AlTER TABLE query. You need to specify multiple alter statements. Refer BOL for ALTER TABLE
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-01-17 : 07:06:27
Thank you sunil

Go to Top of Page

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-01-17 : 07:12:22
It seems you are just beginning to learn sql. I will suggest you to go through following links to get a idea about SQL.
http://www.sql-tutorial.net
http://www/w3schools.com

Get a beginners SQL book and practise SQL exercises.
Go to Top of Page
   

- Advertisement -