Multiple alter commands in a stored procedure

Posted on 2006-03-21
Last Modified: 2012-06-21
I would like to run two alter procedures on a table but I don't seem to be able to combine them into a single stored procedure as they require the 'Go' command between executions. Please could someone explain where i am going wrong?

Many thanks in advance
Question by:dchoxford
    1 Comment
    LVL 75

    Accepted Solution

    Hi dchoxford,
    You can make use of dynamic sql

    declare @sql  nvarchar(4000)

    SET @sql = 'ALTER Table1 Add Column1 int; go; ALTER Table2 Add Column2 int;'
    EXEC sp_executeSQL @Sql


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    779 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

    16 Experts available now in Live!

    Get 1:1 Help Now