Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4581200
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:53:30+00:00 2026-05-21T20:53:30+00:00

I use the SQL script that was generated (sql 2k5), to add a column

  • 0

I use the SQL script that was generated (sql 2k5), to add a column to a table.

I need to add a “check if exists” because my clients sometimes run the script twice. (i have no control over this part, and this is happening over and over again)

I found a way joining the sysobjects and syscolumns, it works.

My problem is that I have to add a column to an other table, where the column is not at the end of the table.

For this one, SQL is generating that long code … create new temp table with the new column, filling up from old table, dropping the old table, and finally renaming the temp table.

The issue here is that the script for this one has lots of GO -s in there along with transactions …

What can i do?

1.) remove all the GO – s? (don’t like the idea)

2.) adding my IF between every GO pair? (don’t like the idea)

3.) is there an other way that makes sense, and it would not be too hard to implement

I cannot think of anything really, I could check for release version, or anything, not just my sysobjects and syscolumns join, but the issue will be the same.

because of the GO-s, my If will be “forgotten” when it gets to the END of the BEGIN …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:53:31+00:00Added an answer on May 21, 2026 at 8:53 pm

    How are they running the scripts (since you are using a tool which supports the GO batch separator) – SQL CMD?

    I would consider putting it all in a string and using EXEC. Several DDL commands have to be the first command in a batch. Also, you can sometimes run into parsing issues:

    ALTER TABLE Executing regardless of Condition Evaluational Results

    Also, you may want to look at SQLCMD’s control features http://www.simple-talk.com/sql/sql-tools/the-sqlcmd-workbench/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a T-SQL script that I plan on re-running, often times I use
We use SQL Server 2000/2005 and Vault or SVN on most of our projects.
I want to use SQL Profiler to trace the queries executed agains my database,
Can I use SQL Authentication with User Instances?
Has anyone attempted to use SQL Server Database as a Subversion file system back
I usually do not use Sql Server Management Studio, I usually use Linqpad to
I'm trying to use SQL Server 2000 DTS Package to download a file from
What is the best way to use SQL Server 2008 as a development database,
Possible Duplicate: Internationalization in SSRS We use SQL Server Reporting Services for our web
Does it make sense to use SQL Server Compact for a desktop application? How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.