0
create proc PrAspnet_RolesGet
as

select  r.RoleId, r.RoleName, lr.RoleId as IsLoginetRole
from aspnet_Roles r

left join loginetRoles lr
on r.RoleId = lr.RoleId

The table loginetRoles contains one field - the RoleId. How can I replace the field IsLoginetRole from Guid value to bit value?

Farzin Zaker
  • 3,578
  • 3
  • 25
  • 35
Alexandre
  • 13,030
  • 35
  • 114
  • 173
  • 2
    There is no boolean datatype. Only `bit`. What should the logic be for the conversion from `guid` to `bit`? You want to return `1` if `NOT NULL` and `0` if `NULL` or something? – Martin Smith Apr 26 '11 at 09:07
  • Martin, Yeah. I want to return 1 if NOT NULL and 0 if NULL. – Alexandre Apr 26 '11 at 09:10

1 Answers1

3
SELECT r.RoleId,
       r.RoleName,
       CAST(CASE
              WHEN lr.RoleId IS NULL THEN 0
              ELSE 1
            END AS BIT) AS IsLoginetRole
FROM   aspnet_Roles r
       LEFT JOIN loginetRoles lr
         ON r.RoleId = lr.RoleId  
Martin Smith
  • 438,706
  • 87
  • 741
  • 845