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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to catch specific exception?

Author  Topic 

noob20
Starting Member

1 Post

Posted - 2011-01-12 : 00:03:35
Table1 (username,email,phoneno)

I have applied unique constraints to username column and email column.
I made one stored procedure to insert this data.I have added try and catch block.In catch block I have added statement
PRINT "Insert failed"

I want users to show the specific exception.How can I know on which column exception is occured?

If username inserted alreay exists in table it should raise error like "Username already exists" AND if email inserted already exists in table it should raise error like "Email alreadt exists".

Thanks in advance.

Sachin.Nand

2937 Posts

Posted - 2011-01-12 : 00:18:28
Check for RAISERROR in BOL.

PBUH

Go to Top of Page
   

- Advertisement -