I am trying to learn how to create error checking in my stored procedures, and apparently I am having some problems with it can anyone help me out pls??
CREATE PROCEDURE [InsertGCTerms]
AS
INSERT INTO [CommissionEmployee_Exclusionsdb].[dbo].[GCEmployeeTerms]([TM #],[FirstName],[LastName],[SocialSecurityNumber],[DateHired],[DepartmentName],[Title])
SELECT a.[TM#], a.LASTNAME, a.FIRSTNAME, a.[SSN#], a.HIREDATE,
a.[DEPT#], a.JOBTITLE FROM GOVEMPLYS AS a
WHERE a.STATUS = 'TERMINATED'
RETURN
GOCan you coach us just a bit on what to do if an error occurs? You can always use the "panic, scream, and shout" approach, but I generally prefer something just a bit more elegant!
-PatP|||I was trying to use the @.@. Error system function|||It appears that I'm not making my question very clear. Let's go for the ever loving example, maybe that will help!CREATE PROCEDURE [InsertGCTerms]
AS
INSERT INTO [CommissionEmployee_Exclusionsdb].[dbo].[GCEmployeeTerms] (
[TM #], [FirstName], [LastName]
, [SocialSecurityNumber], [DateHired], [DepartmentName]
, [Title] ) SELECT
a.[TM#], a.FIRSTNAME, a.LASTNAME
, a.[SSN#], a.HIREDATE , a.[DEPT#]
, a.JOBTITLE
FROM GOVEMPLYS AS a
WHERE a.STATUS = 'TERMINATED'
IF 0 <> @.@.error RAISERROR ('Scream and shout, run and panic!')
RETURN
GO-PatP|||Ok sorry I see your point..LOL that was funny, need a good laugh in the morning. sorry I didnt make myself clear. But basically pat you already answered my question and now I see where I went wrong. I am so glad I ordered the http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=bsq1M1M1GT&isbn=1565924010&itm=1 Book this will help me out tremendously, I need a book all about programming in sql.|||I would look at
Ken Hendersons Book (http://search.barnesandnoble.com/booksearch/isbninquiry.asp?userid=6F22YrtiAX&pwb=1&ean=9780201615760)
Also...did someone say error handling?
http://weblogs.sqlteam.com/brettk/archive/2004/05/25/1378.aspx|||Yes I originally ordered that book but apparently it was out of stock or something, they refunded my money back got the message via email. Yes I was inquiring about Error Handling|||Amazon out of stock?
I doubt it
And did you look at my link?
Follow the steps to save the tql file to your machine...|||ok Brett I ordered the book, those two should help me out tremendously. Thank you :)|||Great...but did you look at the error handling tql file in my blog?|||Yes Brett I am looking that over now thank yoiu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment