CREATE TABLE dbo.emp ( empno int NOT NULL) go create procedure dbo.p_emp_insert (@empno int) as begin -- CODE THAT MAY FAIL begin try insert into emp (empno) values (@empno) end try -- EXECUTED IF THERE IS A FAILURE begin catch SELECT ERROR_NUMBER()as ERROR_NUMBER, ERROR_SEVERITY()as ERROR_SEVERITY, ERROR_STATE()as ERROR_STATE, ERROR_MESSAGE()as ERROR_MESSAGE end catch end -- First exec should...
work with a valid empno … exec dbo.p_emp_insert 1003 -- This should fail because the column does not allow NULLs -- We should see the error information returned exec p_emp_insert NULL
Dig Deeper on SQL Server Stored Procedures
Convert SQL Server 2000 DTS packages to SQL Server 2005 with this advice and also see how to overwrite data.continue reading
Is there a query to search text in a SQL Server DTS package? SQL Server expert Joe Toscano explains which database objects can be viewed.continue reading
Getting an error when importing data from an Excel spreadsheet to SSIS in SQL Server 2005? Try lining up data types in Excel and SSIS so they match.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.