SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

ChrisjBrown
Starting Member

United Kingdom
7 Posts

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

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)
BEGIN
INSERT INTO enrollment
VALUES (s_id, c_code, e_date);
END

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?

tkizer
Almighty SQL Goddess

USA
36672 Posts

Posted - 05/25/2014 :  19:11:09  Show Profile  Visit tkizer's Homepage  Reply with Quote
Use a Try/Catch block: http://msdn.microsoft.com/en-us/library/ms175976.aspx

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000