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
 General SQL Server Forums
 New to SQL Server Programming
 Raiserror

Author  Topic 

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-16 : 01:36:36
hey all,

just cant figure out why my raiserror print
Wrong RoleType for customer lientID
for :-
RAISERROR('Wrong RoleType for customer %ClientID', 16,1, @ClientID)

what's with missing C? is % some kind of escape char or something? (im trying to print back the parameter @clientid), or should i just use the print ''

~~~Focus on problem, not solution~~~

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-04-16 : 01:59:11
replave clientid with d, then u can get it

Declare @ClientID int
select @ClientID = 1

RAISERROR('Wrong RoleType for customer %d', 16,1, @ClientID)

0utput
--------
Server: Msg 50000, Level 16, State 1, Line 6
Wrong RoleType for customer 1
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-16 : 02:45:12
www.sommarskog.se/error-handling-I.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-16 : 04:48:41
hey all, thanks

~~~Focus on problem, not solution~~~
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-16 : 05:02:37
helo again,
what's wrong with this when @Clientid as varchar?

declare @clientid1 as varchar(10)
set @ClientID1='JABPB'

RAISERROR('Client1 : %d', 16,1,@ClientID1)

giving me --> Client1 : 399292452
Not Client1 : JABPB

tq

~~~Focus on problem, not solution~~~
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-16 : 05:04:46
RAISERROR('Client1 : %s', 16,1,@ClientID1)

I THINK IT IS TIME YOU ACTUALLY READ ABOUT RAISERROR FUNCTION ON BOOKS ONLINE!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-04-16 : 07:21:37
:(
it is fronm BOL the sample..

~~~Focus on problem, not solution~~~
Go to Top of Page
   

- Advertisement -