Jump to content

Adding more than one column in sql server


MyronCope

Recommended Posts

I am trying to write a script to insert more than one column but the script I am making only inserts the column in the second line and I dont know why. In my code below, columnB is added to the table, but not columnA. I am stumpedMy sql is:

Alter table  [dbName].[dbo].[tableName] Add columnA bit Default 0 Not NullAlter table  [dbName].[dbo].[tableName] Add columnB bit Default 0 Not Null

thanks for your help.

Edited by aspnetguy
Link to comment
Share on other sites

  • 2 weeks later...

You don't need to write the ALTER table statement twice, you can separate the fields with commas:

ALTER TABLE dbname.dbo.tablenameADD columnA bit Default 0 Not Null, columnB bit Default 0 Not Null

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...