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.
| Author |
Topic |
|
tomex1
Starting Member
47 Posts |
Posted - 2008-08-07 : 11:27:50
|
| Hi all, I am trying to print a friendly error message in my procedure. My procedure contains a select statement and want to be able to print my custom message whenever the select statement returns more than on row. Please, how do I do this?Kind regards,Segun |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-07 : 11:30:08
|
| use RAISEERROR http://blogs.techrepublic.com.com/datacenter/?p=390 |
 |
|
|
tomex1
Starting Member
47 Posts |
Posted - 2008-08-07 : 11:42:43
|
quote: Originally posted by visakh16 use RAISEERROR http://blogs.techrepublic.com.com/datacenter/?p=390
Hi, many thanks for this but I am not sure if this is what I need. I would have thought I could use an 'IF' statement or something along that line.Kind regards,Segun |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-07 : 14:54:52
|
| yes you can. visakh16 was merely saying that you could use RAISERROR to actually print the message.You would do an IF condition I guess like this..<your query>IF @@ROWCOUNT > 1 BEGINRAISERROR('yourMessage', severity (number from 1 to 20 I think), level (an INT)ENDCheck out books on line for more info.RAISERROR also accepts a WITH (NOWAIT) command which means that the string is returned to your application / the screen immediately rather than waiting for caching.EXAMPLERAISERROR('Hello World', 0, 1) WITH NOWAIT-------------Charlie |
 |
|
|
|
|
|