473,854 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"GO" used in a stored procedure

I have a stored procedure in sql 2000 that requires steps to be fully
completed before moving to the next command in the procedure. I have
tried to place the word "GO" after each statement. When I create the
procedure then take a look at it through em, it only shows the code up
until the word "GO".

Example:
CREATE PROCEDURE mytest
as
create table mytable col1 varchar(5), col2 varchar(10)
GO
insert into mytable (col1, col2) values(abc, def)

All i see is:
CREATE PROCEDURE mytest
as
create table mytable col1 varchar(5), col2 varchar(10)
GO
I need to be 100% certain that the table has already been created
before trying to add records to it.

Is there any command that makes t-sql halt until the previous command
has finished?

Thanks,
Dave
Jul 20 '05 #1
6 39159
GO isn't a TSQL command. It marks the end of a batch in Query Analyzer and
therefore signals the end of a stored procedure definition in that batch, so
it cannot be part of an SP.

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
Dave wrote:
I have a stored procedure in sql 2000 that requires steps to be fully
completed before moving to the next command in the procedure. I have
tried to place the word "GO" after each statement. When I create the
procedure then take a look at it through em, it only shows the code up
until the word "GO".

Example:
CREATE PROCEDURE mytest
as
create table mytable col1 varchar(5), col2 varchar(10)
GO
insert into mytable (col1, col2) values(abc, def)

All i see is:
CREATE PROCEDURE mytest
as
create table mytable col1 varchar(5), col2 varchar(10)
GO
I need to be 100% certain that the table has already been created
before trying to add records to it.

Is there any command that makes t-sql halt until the previous command
has finished?

Thanks,
Dave


You can be assured that the table will be created before the insert
statement is executed. Each command will be 100% finished and committed
before moving on to the next statement (unless you using transactions).

Zach
Jul 20 '05 #3


David,

Thanks for responding so quickly. I did read in several places that the
GO command does exactly what you have stated.

However, I still need to find a way to make sure that my code is
finished executing before moving to the next step within my stored
procedure.

The example I posted earlier was really dummied down from what I really
need to do. We have some procs here that are over 600 lines of code, and
most of them depend on the previous chunk of code to have completed
before they execute.

Any other ideas would be greatly appreciated.
Thanks,
Dave

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Dave F wrote:

David,

Thanks for responding so quickly. I did read in several places that the
GO command does exactly what you have stated.

However, I still need to find a way to make sure that my code is
finished executing before moving to the next step within my stored
procedure.

The example I posted earlier was really dummied down from what I really
need to do. We have some procs here that are over 600 lines of code, and
most of them depend on the previous chunk of code to have completed
before they execute.

Any other ideas would be greatly appreciated.
Thanks,
Dave

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Like I said, SQL will ALWAYS complete a command before moving on to the
next one. What makes you think this doesn't already happen?

Zach
Jul 20 '05 #5
[posted and mailed, please reply in news]

Dave (fu*****@yahoo. com) writes:
Is there any command that makes t-sql halt until the previous command
has finished?


To echo what Zach said: there is no command that causes T-SQL to continue
with the next command, before the previous has completed. So you
have no reason to worry.
--
Erland Sommarskog, SQL Server MVP, so****@algonet. se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6
This is a catch 22 situation.

Do you really need to create a new table each time you execute the stored proc?
If so, use temporary tables.

Otherwise empty your existing table before you insert rows.
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1663
by: Karl | last post by:
I work for a software company that's looking to get into .NET. I've dabbled with the technology for a bit, and had some positive resutls. My boss is asking me that he wants to buy a framework that delivers a lot of the common functionality that .NET developers need. Things like generating DataSets to call against databases, generating code for Windows and Web Forms, deploying the applications and so on. He's nervous that we're going...
6
27776
by: Harald Weiser | last post by:
Hi you out there. I use the following string to go back to a page that's in the history. <A HREF="javascript:history.go('dosearch=0')"> But nothing happens. Using the complete URL makes no difference :-( Suggestions? THX, Harry
17
2017
by: Will Hartung | last post by:
I have a table for a report. It can get wide, but that's no big deal. I don't mind that it can get wide. What I do mind, though, is the browser doing its damndest to smash the thing down to get it to fit the window (to no avail). It crams it down until it can't cram any more and then pops up the horizaontal scroll bar, rather than just "let go", and set the table free, scrollbar be damned. Is there a way to tell the browser that my...
1
1686
by: vj | last post by:
Is there a "go to" statement in DB2 Stored Procs.
1
20674
by: AA Arens | last post by:
I my form I have put record navigation buttons. When I choose just before the last record, the "Go to next record" button, access automatically start with a new record instead of a message that theere are no records after. I do have a command that automatically jumps to the last record after I open the form: Private Sub Form_Load() DoCmd.GoToRecord , , acLast
7
4988
by: Rob | last post by:
In a previous thread, I was asking about setting up my global.aspx which inherits System.Web.HttpApplication. This is where there are the event handlers like: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) In this file I've got: Private WithEvents ApplicationTimer As System.Timers.Timer ' used to
5
5930
by: Fred Hebert | last post by:
I was thinking of switching to VS2005, so I sent off for and received a 120 evaluation kit. This version was supposed to be the same as the full version, but the key limits you to 120 days. I installed it and began learning how to use it. I built several small C# test apps that use common classes in a dll that I also wrote. When I right click on a class that was defined in the dll and select "go to definition" it would open the source...
0
920
by: Tequilaman | last post by:
Has anybody here every created a program to insert data from a csv into a webform, including a click to a 'go on' button and choosing in dropdowns according to the information in the csv? I'm trying something like this, based on an existing prog. sadly the prog is in C# which I don't know. Now I try to rebuild that in visual basic and build in the new functionality. I mainly run into problems how to choose from the pulldowns and click the 'go...
7
1558
by: Scott McNair | last post by:
Hi, I'm trying to set an environment variable programmatically. I've added these three lines to my code: System.Environment.SetEnvironmentVariable("TCS", "C:\Program Files\TCS\") InstallPath = System.Environment.GetEnvironmentVariable("TCS") MsgBox(InstallPath) And, as expected, the MsgBox contains "C:\Program Files\TCS\".
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10766
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7083
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5946
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4167
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.