How do I add new columns to a SQL table via script

Posted on 2007-10-01
Last Modified: 2008-01-09

I new to sql server 2005. I am developing a db locally and wanted to push a script that copies table design changes over to the production environment. I tried using a script like the one below using the built-in script generator, but I get an error when using it.
Msg 102, Level 15, State 1, Line 21
Incorrect syntax near '<'.
What's the easiest way to get this accomplished?


INSERT INTO [ht-cms-shell].[dbo].[CN_CLIENT]
           (<CN_START_DATE, datetime,>
           ,<CN_EXP_DATE, datetime,>
           ,<GF_ID, decimal(18,0),>
           ,<TC_ID, decimal(18,0),>
           ,<CN_ACCOUNTING_ID, nvarchar(25),>)
Question by:htamraz1
    LVL 16

    Expert Comment

    Use the import/export wizard provided by SQL Server 2005
    LVL 75

    Accepted Solution

    best and easiest option, is to use some thir party db compare tools like red gate's sql compare, which will give you the script to be applied into the production server comparing both these schemas

    U can download the 14  days trial version from
    LVL 18

    Expert Comment

    The script you posted is something the -- once the syntax is correct -- will insert a record into the table CN_CLIENT ... that is ... it is not adding a column to any table. That would be:

    alter table add column [Column1] integer
    ... or something similar

    Hope this helps ...
    LVL 18

    Expert Comment

    It is *** VERY *** good practice to script out your datamodel modifications (Database Definition Language = DDL), so you can use that DDL later for deployment to other environments. So develop them in the development environment and rerun the script when deploying to Test, Accept and Production environments !

    Third party tools are good, ... as long as they provide you the script !!! Don't go 'clicking' the modifications on each and every server or database ... it's the famous accident waiting to happen. ... and it WILL happen on the production environment :-) ... Murphy loves databases as well :-)

    hope this helps ...

    Author Comment

    Thanks all. Let me try your suggestions and we'll be back with my accept or request for additional clarification.

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now