Reputation: 27
CREATE PROCEDURE [dbo].[AdminCheck] (@Name nvarchar, @Password int)
AS
Select * from Admin
where AdminName = @Name AND AdminPassword = @Password
Go
Above is my stored procedure
I got Admin
as AdminName
and 123
as AdminPassword
in Admin
table.
When I run it it does not work.
Upvotes: 0
Views: 57
Reputation: 11
you can call it like this. Please send error message.
exec [dbo].[AdminCheck] 'Admin',123
Upvotes: 0
Reputation: 24144
You defined your parameter as a NVARCHAR - it means ONE symbol.
CREATE PROCEDURE [dbo].[AdminCheck] (@Name nvarchar, @Password int)
So when you call it AdminCheck('Admin',123)
then @Name
is actually 'A'
not 'Admin'
It should be for example:
CREATE PROCEDURE [dbo].[AdminCheck] (@Name nvarchar(100), @Password int)
Upvotes: 1
Reputation: 9365
When you say
@Name nvarchar
The size of the variable will be 1 by default:
Hence your query will be compared to the first character of @Name
variable:
Provide proper size for your variable;
@Name nvarchar(150)
Upvotes: 2