Solved

Return success or failure from stored procedure (login)

Posted on 2011-02-11
3
691 Views
Last Modified: 2012-05-11
I have a stored procedure .... basically I want it to return a success (somehow)  if the  table called in the stored procedure has a username and password combo and not sucesful if it does not.

How could I bet do this?
0
Comment
Question by:vbnetcoder
  • 2
3 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 34875373
use function

create function login(parameters here) as int
begin
 ...
 if (....) return 0 else return 1; ' 0:success, 1 failed
end;
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34875405
actually syntax is

create function login(@p1 integer, @p2 varchar) returns integer as
begin
  declare @result integer =0;
  select @result = sign(count(1)) from users where userid=@p1 and password=@p2;
  return @result; -- 0 : failed, no such user, 1: success there is a user with that password  
end;
0
 

Author Closing Comment

by:vbnetcoder
ID: 34875469
TY
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What's wrong with this T-SQL Foreign Key? 7 51
PROPERCASE SCRIPT IN SQL 3 16
Where on a calculated field 1 21
TSQL convert date to string 4 34
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question