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
Migrate DTS packages to SQL Server Integration Services with Migration Wizard and deploy SSIS packages in SQL 2005. Learn how to access DTS Designer ...continue reading
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
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.