[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Multiple alter commands in a stored procedure

Posted on 2006-03-21
1
Medium Priority
?
285 Views
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
0
Comment
Question by:dchoxford
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 16248807
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

Cheers!
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

834 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