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)
 exception handling

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-21 : 09:08:35
hi are you having any idea how to write this particluar thing in sql server 2005?if so please help me out in this.

EXCEPTION
WHEN TOO_MANY_ROWS THEN
BEGIN
SELECT ---------
END;

how to handle this in sql server 2005?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-21 : 09:38:10
TOO_MANY_ROWS isn't that ORACLE?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-21 : 09:43:20
yes is there anything that i need to handle

as my select query is like this


Begin
If (@PLocationid =0)
Begin
SELECT @PUserName=A.USER_LOGIN,@PUserFullName=A.USER_NAME, @PRoleName= B.ROLE_NAME, @PGroupid =B.GROUP_ID,@PLocationName= '', --AS LOCATION_NAME,
@PRoleabbrid= B.ROLE_ABBR_ID ,@PUserTheme=F.THEME_NAME
FROM USERS A, EMRUserRoleLocation B, EMRRoleAbbreviationLkup C ,EMRThemesLkup F
WHERE ((Upper(A.USER_LOGIN))) = ((Upper(@PLoginName))) AND A.USER_THEME = F.THEME_ID AND A.USER_LOGIN = B.USER_LOGIN AND
((A.USER_PASS)) = ((@PPassWord)) AND B.ROLE_NAME = C.ROLE_NAME AND A.USER_THEME = F.THEME_ID AND A.USER_STATUS ='active' AND A.LOCKED_USER <> 1
ORDER BY C.ROLE_PRIORITY ASC
IF @@ROWCOUNT >1
Begin
SELECT @PUserName= A.USER_LOGIN,@PUserFullName=A.USER_NAME,@PRoleName= B.ROLE_NAME, @PGroupid= B.GROUP_ID,@PLocationName= '', --AS LOCATION_NAME,
@PRoleabbrid=B.ROLE_ABBR_ID, @PUserTheme=F.THEME_NAME
FROM USERS A, EMRUserRoleLocation B, EMRRoleAbbreviationLkup C , EMRThemesLkup F
WHERE ((Upper(A.USER_LOGIN))) = ((Upper(@PLoginName))) AND A.USER_LOGIN = B.USER_LOGIN AND
((A.USER_PASS)) = ((@PPassWord)) AND B.ROLE_NAME = C.ROLE_NAME AND A.USER_THEME = F.THEME_ID AND A.USER_STATUS ='active' AND A.LOCKED_USER <> 1
ORDER BY C.ROLE_PRIORITY ASC;
SET @PSelectStat = ' SELECT A.USER_LOGIN + A.USER_NAME + CAST(B.GROUP_ID AS VARCHAR) + '''' AS LOCATION_NAME + B.ROLE_ABBR_ID + B.ROLE_NAME + F.THEME_NAME as Fld'
SET @PSelectStat = @PSelectStat + ' FROM USERS A, EMRUserRoleLocation B, EMRRoleAbbreviationLkup C , EMRThemesLkup F '
SET @PSelectStat = @PSelectStat + ' WHERE ((Upper(A.USER_LOGIN))) = ((Upper(PLoginName))) AND A.USER_LOGIN = B.USER_LOGIN AND '
SET @PSelectStat = @PSelectStat + ' ((A.USER_PASS)) = ((PPassWord)) AND B.ROLE_NAME = C.ROLE_NAME AND A.USER_THEME = F.THEME_ID AND A.USER_STATUS =''active'' AND A.LOCKED_USER <> 1 '
SET @PSelectStat = @PSelectStat + ' ORDER BY C.ROLE_PRIORITY ASC'
SET @PQueryFlag =1

End
-----------------------------------------------
End

Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-21 : 09:44:35
can you correct if anywrong in it?
Go to Top of Page
   

- Advertisement -