Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create procedure hanging

Status
Not open for further replies.

Luvsql

Technical User
Apr 3, 2003
1,179
CA
I've created a sp and because of the multitude of joins and thousands of records it creates, I know that it will cause significant performance issues, so I will be scheduling it to run at night and use the table it updates for our reports.

When I am trying to create the procedure within EM, the check syntax is fast with no errors, but when I click on Ok, it sits and hangs for quite a while, then I look back and it has deleted most of the syntax.

I have deleted the sp and pasted the syntax in query analyzer, but it's now at 6 minutes without doing anything. Why is it taking so long just to create the procedure (ie creating the procedure should not actually run the syntax)?
 
Just because the syntax check comes back clean and fast does not mean the SP is phyically correct. You may have some joins to remote servers that may have rights issues that are not being returned. May be you are using cross database calls w/ the same issue.

Try breaking the SP down into workable parts. As each part "saves" correctly, reopen the SP add the next code block and continue. Maybe you can find the rouge section this way.

Thanks

J. Kusch
 
You could post the procedure code, probably something in it is not right.

Questions about posting. See faq183-874
 
If I remove the delete statement, it creates in seconds.

ie

create procedure TEST
as
insert into table1
select statement
go

This creates fine and in seconds.

create procedure TEST
as
delete table1
go
insert into table1
select statement
go


This hangs and doesn't create.
 
I created 2 steps for my job (one to delete table, second to run sp). It's crazy that I can't add a delete into the sp.
 
You can't put go statements inside a stored procedure. The problem that you are having is that when it gets to the first go it uses that as the end of the procedure. The rest of the code is being executed.
Code:
[COLOR=green]
create procedure TEST
as
delete table1
go
[/color]
[COLOR=red]
insert into table1
select statement
[/color]
go
The green code is being created as the procedure, while the red code is simply being executed against the server.

The GO command is called a batch seperator. Since stored procedures can only support a single batch within there code, the GO command ends the stored procedure.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top