RachelDosSantos
asked on
stored procedure not returning uniqueidentifier
hi there,
id like the stored procedure bellow to return a uniqueidentifier. however, its returning an integer and i get the following exception
"Msg 206, Level 16, State 2, Procedure GetUserIdByUserName, Line 18
Operand type clash: uniqueidentifier is incompatible with int"
id like the stored procedure bellow to return a uniqueidentifier. however, its returning an integer and i get the following exception
"Msg 206, Level 16, State 2, Procedure GetUserIdByUserName, Line 18
Operand type clash: uniqueidentifier is incompatible with int"
ALTER PROCEDURE [dbo].[GetUserIdByUserName]
(
@UserName nvarchar(256)
)
AS
SET NOCOUNT ON;
DECLARE @return_value uniqueidentifier
set
@return_value = (SELECT UserId as userID
FROM aspnet_Users
where UserName = @UserName)
return @return_value;
ASKER
userid field is uniqueidentifier and that is the type i need this procedure to return
ASKER
CREATE TABLE [dbo].[aspnet_Users](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
....
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
....
does this query
SELECT UserId as userID
FROM aspnet_Users
works on your system ? If not, try this one
SELECT [UserID]
FROM aspnet_Users
if this works,change the query inside your procedure and it should work
SELECT UserId as userID
FROM aspnet_Users
works on your system ? If not, try this one
SELECT [UserID]
FROM aspnet_Users
if this works,change the query inside your procedure and it should work
This would suffice:
or a simple SELECT statement would do instead of a procedure:
SELECT UserId as userID
FROM aspnet_Users
where UserName = ?
or a simple SELECT statement would do instead of a procedure:
SELECT UserId as userID
FROM aspnet_Users
where UserName = ?
ALTER PROCEDURE [dbo].[GetUserIdByUserName]
(
@UserName nvarchar(256)
)
AS
SELECT UserId as userID
FROM aspnet_Users
where UserName = @UserName
GO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ALTER PROCEDURE [dbo].[GetUserIdByUserName ]
(
@UserName nvarchar(256)
)
AS
SET NOCOUNT ON;
DECLARE @return_value uniqueidentifier
set
SELECT @return_value= UserId
FROM aspnet_Users
where UserName = @UserName
return @return_value;
(
@UserName nvarchar(256)
)
AS
SET NOCOUNT ON;
DECLARE @return_value uniqueidentifier
set
SELECT @return_value= UserId
FROM aspnet_Users
where UserName = @UserName
return @return_value;
Inteqam,
You may want to double check that.
You may want to double check that.
Hope it helps.