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
 General SQL Server Forums
 New to SQL Server Programming
 adding the column by using the alter command.

Author  Topic 

argon007
Starting Member

38 Posts

Posted - 2008-06-01 : 03:01:28
[code]ALTER TABLE customers
add column active_flg int(1) [/code]

but i got error.

quote:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'column'.


what should i do?

ps. thanks for warning... i won't edit the post after i got the answer anymore.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-01 : 03:05:16
Don't specify a size for int. You'll also need to specify NULL or a default value. I've used NULL below, but that might not be what you want.

ALTER TABLE customers
add column active_flg int NULL

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

argon007
Starting Member

38 Posts

Posted - 2008-06-01 : 03:16:13
thank you,

tried it, but still the same problem.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-01 : 03:29:52
Oops. Remove the word column.

ALTER TABLE customers
ADD active_flg int NULL

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-01 : 03:32:03
quote:
Originally posted by argon007

thank you,

tried it, but still the same problem.


Use like this

ALTER TABLE customers
ADD active_flag int NULL
Go to Top of Page

argon007
Starting Member

38 Posts

Posted - 2008-06-01 : 03:51:18
thank you, got solved.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-01 : 04:28:56
quote:
Originally posted by argon007

thank you, got solved.


You're welcome
Go to Top of Page
   

- Advertisement -