Friday, February 24, 2012

how i use the N Switch in Stored Procedure

Any One Tell me how i can use N'Switch in SQL Server Stored Procedure .
When I use Such a this syntax i am encountered and stoped with a error.
the is below(Stoerd Prdocedure Code)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
CREATE proc sp_check_userpass(@.username nvarchar(50),@.password nvarchar(50),@.first nvarchar(50),@.last nvarchar(50),@.email nvarchar(50),@.stage int )as
declare @.cnt int
begin
select @.cnt=count(*) from member_info where (@.username=username and @.password=password)
if(@.cnt=0)
begin
insert into atable(first,last,username,password,stage) values(@.first,@.last,@.username,@.password,@.stage)
end
else
return @.cnt
end
GO
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Other thing is that when exec this store proc it must be return a value return back to the @.cnt but it is return only This( The command(s) Completed succefully).
Any One guide me how i can must be do .
i must clear it that i am using this query in ASP.NET SqlClient Object To Execute Query.
Thanx In Advance. ArQaI can't see any use of the unicode string constant prefix (i.e. N'Hello world') in your procedure. Did I miss something?

A UDF (User Defined Function) might better suit your needs than a stored procedure, although a UDF couldn't write to a table in order to log the failure for you. Very few client tools have the ability to support return values from stored procedures, although that is possible in most of the languages that support ADO.NET. You can get more information about this in KB#308051 (http://support.microsoft.com/default.aspx?scid=kb;en-us;308051).

-PatP

No comments:

Post a Comment