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 2005 Forums
 Transact-SQL (2005)
 how can I include my local var in RAISERROR?

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2010-04-07 : 11:18:22
I would like to show the conflict date in the error msg returned to my app.
and as a bonus if I could short format it here would be great..



Declare @newEffective datetime
Select @newEffective = effdate from inserted
print @count
IF @count > 0
Begin
RAISERROR 50009 'Effective date ' + CAST(@newEffDate, NVARCHAR(14)) + ' conflicts choose another effdate. '
ROLLBACK TRANSACTION
RETURN
end
Begin

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2010-04-07 : 11:23:31
think i found the answer right after..

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=67771
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-07 : 11:28:19
Just to start with:

Declare @count int
Declare @newEffective datetime
Select @newEffective = '2010-04-10'
set @count = 10

Declare @RetMsg varchar(1000)

Set @RetMsg = 'Effective date ' + Convert(varchar,@newEffective,120) + ' conflicts choose another effdate. '


IF @count > 0
Begin
RAISERROR (@RetMsg,16,1)
ROLLBACK TRANSACTION
RETURN
end

Regards,
Bohra
Go to Top of Page
   

- Advertisement -