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-11 : 19:59:14
|
Hello All, I am trying to use RAISERROR to print a custom error message but it doesn't seem to be working. I am using it in this procedure so that if @ContactCount is not qual to 1 i want to print a custme eror message but it doesn't appear to do anything. Please helpl :USE [wce_sqlexpress]GO/****** Object: StoredProcedure [dbo].[history_proc] Script Date: 08/11/2008 19:44:51 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER procedure [dbo].[history_proc]@recordedtime datetime,@recordedfor varchar(16), @subject varchar(50),@notes text,@uniqueid varchar(16),@etable varchar(100),@utable varchar(100),@contact varchar(100),@emailaddress nvarchar(75),@htype varchar(20)ASdeclare @entityid varchar(16)declare @recordmanager varchar(16)declare @ContactCount intSET NOCOUNT ONSET @ContactCount = (select count(*) from wce_contact where emailaddress = @emailaddress)IF @ContactCount = 1BEGINset @entityid = (select UNIQUEID from wce_contact where emailaddress = @emailaddress)set @recordmanager = (select wce_sys..wces_users.UNIQUEID from wce_sys..wces_users where wce_sys..wces_users.WCE_UID = @recordedfor and wce_sys..wces_users.WCE_ALIAS = 'wce_sqlserver')insert into wce_linkto (LEntityID, LETableName, LUniqueID, LUTableName)VALUES (@entityid, @etable, @uniqueid, @utable)SEt NOCOUNT OFF insert into wce_history (UNIQUEID, RECORDEDTIME, RECORDEDFOR, SUBJECT, NOTES, HTYPE)VALUES (@uniqueid, @recordedtime, @recordmanager, @subject, @notes, @htype)ENDELSEBEGIN RAISERROR (50001,1,1)END |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-08-11 : 22:33:23
|
Like this:IF @ContactCount <>1 BEGIN RAISERROR ('An error occured with contactcount',10,1) END |
|
|
tomex1
Starting Member
47 Posts |
Posted - 2008-08-12 : 02:03:06
|
quote: Originally posted by sodeep Like this:IF @ContactCount <>1 BEGIN RAISERROR ('An error occured with contactcount',10,1) END
|
|
|
tomex1
Starting Member
47 Posts |
Posted - 2008-08-12 : 02:03:07
|
quote: Originally posted by sodeep Like this:IF @ContactCount <>1 BEGIN RAISERROR ('An error occured with contactcount',10,1) END
Hi Sodeep, I tried that but SQL Server is not printing the custom error message. This is the message I got:"Could not save to database.(Unknown error:Database returns an empty error message.)(SyncFolder) |
|
|
|
|
|
|
|