Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
petebob796
Starting Member
35 Posts |
Posted - 2008-02-08 : 19:11:36
|
| I know this is probably simple but I am trying to call a stored procedure from another stored procedure. Basically this is so I can group lots of table updates into one overnight procedure to run. I don't need a record return using temp tables which is the only reference I seem to be able to find about stored procedures in stored procedures. I just want it to run. Tried the obvious:exec [UStudent_Marks_Filtered]Help much appreciated. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-02-08 : 20:01:36
|
| What you have posted is what you would need to use if you just want it to run. But you may need to pass parameters. Are you getting an error?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
petebob796
Starting Member
35 Posts |
Posted - 2008-02-08 : 20:18:32
|
| The exact code I was trying is:CREATE PROCEDURE [dbo].[USecondary Tables] ASBEGINdelete from [Student Marks Filtered]GOexec [UStudent Marks Filtered]GOdelete from [RegisterDetails Filtered]GOexec [URegisterDetails Filtered]GOSET ARITHABORT OFFSET ANSI_WARNINGS OFFdelete from [Attendance Group]goexec [UAttendance Group]GOdelete from [Attendance RegisterID]goexec [UAttendance RegisterID]godelete from [Attendance Session]goexec [UAttendance Session]godelete from [Attendance Static]goexec [UAttendance Static]godelete from [Attendance ProgArea]goexec [UAttendance ProgArea]godelete from [Attendance Division]goexec [UAttendance Division]godelete from [Attendance School]goexec [UAttendance School]godelete from [Attendance College]goexec [UAttendance College]godelete from [Attendance StudentOverall]goexec [UAttendance StudentOverall]godelete from [Attendance Group Filtered]goexec [UAttendance Group Filtered]godelete from [Attendance Register Filtered]goexec [UAttendance Register Filtered]godelete from [Attendance ProgArea Filtered]goexec [UAttendance ProgArea Filtered]godelete from [Attendance College Filtered]goexec [UAttendance College Filtered]goendand the error I get is:Msg 102, Level 15, State 1, Procedure USecondary Tables, Line 4Incorrect syntax near 'Student Marks Filtered'.Msg 2627, Level 14, State 1, Procedure UStudent Marks Filtered, Line 4Violation of PRIMARY KEY constraint 'aaaaaStudent Marks Filtered_PK'. Cannot insert duplicate key in object 'dbo.Student Marks Filtered'.The statement has been terminated.(1486 row(s) affected)(1486 row(s) affected)(2478 row(s) affected)Division by zero occurred.(2478 row(s) affected)(830 row(s) affected)Division by zero occurred.(830 row(s) affected)(648 row(s) affected)Division by zero occurred.(648 row(s) affected)(469 row(s) affected)Division by zero occurred.(469 row(s) affected)(41 row(s) affected)Division by zero occurred.(41 row(s) affected)(19 row(s) affected)Division by zero occurred.(19 row(s) affected)(8 row(s) affected)Division by zero occurred.(8 row(s) affected)(2 row(s) affected)(2 row(s) affected)(3408 row(s) affected)Division by zero occurred.(3408 row(s) affected)(1235 row(s) affected)Division by zero occurred.(1235 row(s) affected)(270 row(s) affected)Division by zero occurred.(270 row(s) affected)(38 row(s) affected)Division by zero occurred.(38 row(s) affected)(2 row(s) affected)(2 row(s) affected)Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'end'.I thought there was a problem with the delete but if I take that out it fails on the first exec line with:Msg 102, Level 15, State 1, Procedure USecondary Tables, Line 5Incorrect syntax near 'UStudent Marks Filtered'.None of the stored procedures require input it's an overnight thing just clears down some tables and recreates them with the latest data. I find it a bit bizare because it seems to be running the stored procedure rather than creating it unless I have been silly it is a bit late here. |
 |
|
|
petebob796
Starting Member
35 Posts |
Posted - 2008-02-08 : 20:22:51
|
| The division by zero messages are expected just in case your wondering it's a student attendance percentage calculation and I handle it setting percentage to zero if they have never attended. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-02-08 : 20:52:09
|
| Get rid of the GO statements in your stored procedure. You don't use those in stored procedures.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
petebob796
Starting Member
35 Posts |
Posted - 2008-02-08 : 20:55:23
|
| of course thanks thought it was something silly |
 |
|
|
|
|
|
|
|