Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 SQL procedure Return text??
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Kingdom
8 Posts

Posted - 05/25/2014 :  16:15:43  Show Profile  Reply with Quote

I have an SQL procedure which enables a user to easily insert records into my database. The code is given below:

CREATE PROCEDURE add_enrollment (IN s_id CHAR(4), IN c_code CHAR(2), e_date DATE)
INSERT INTO enrollment
VALUES (s_id, c_code, e_date);

The procedure enables the user to add a new record to the enrollment table; student_id, course_code and enrollment_date. What I need it to do is have an output parameter return a string of text identifying the reason(s) for the failure. I am relatively new to SQL so I am a bit at a loss. Could anyone help?

Almighty SQL Goddess

38200 Posts

Posted - 05/25/2014 :  19:11:09  Show Profile  Visit tkizer's Homepage  Reply with Quote
Use a Try/Catch block:

Tara Kizer
SQL Server MVP since 2007
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000