display error message if constraint violation

M

mcnews

is there a way for the database to display an error message when a
user violates a constraint?
an age limit for example?

tia,
mcnewsxp
 
S

Sylvain Lafontaine

Not sure but search this newsgroup for the T-SQL function Raiserror.

The problem with Raiserror and other error messages coming from SQL-Server
is that you don't have much control over their display. IMHO, it's much
better to perform all checks yourself; either at the client interface or at
the server using stored procedures.
 
S

Sylvain Lafontaine

As a programmer, it's your choice but you - and your boss - won't find it
funny if you are ever called on an emergency call to help a new girl/oy who
doesn't understand the half cryptic error messages coming from the server.

You can add limiting constraints on the server if you want to be really sure
that some conditions are fulfilled but IMHO, each error message creeping out
of the server to the user - even if only for a single time - should be seen
as the indication of a bug in your client code.
 
M

mcnewsxp

how would you use a stored proc to do it?

Sylvain Lafontaine said:
As a programmer, it's your choice but you - and your boss - won't find it
funny if you are ever called on an emergency call to help a new girl/oy
who doesn't understand the half cryptic error messages coming from the
server.

You can add limiting constraints on the server if you want to be really
sure that some conditions are fulfilled but IMHO, each error message
creeping out of the server to the user - even if only for a single time -
should be seen as the indication of a bug in your client code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top