Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Login Query

Author  Topic 

ravininave
Posting Yak Master

111 Posts

Posted - 2009-10-04 : 06:04:25
Actually My Web Application updates from Client Server Application. So Password field get reset everyday. User Can't change their Password. For that I've created one more Table to store Password. Whenever User enter Password I check it into new Password table. If his ID found then check for Password. If ID Not found then check UserName and Password in Original Table. My Table Structure

Table : AppMain
Code,CustName,Pass

Table:PassTbl
Code,Pass

I've written a stored Procedure like :
CREATE PROCEDURE [dbo].[FindUser]
(@Code_1 [numeric](9),
@Pass_2 [nvarchar](50))

AS
if exists
(select Code from PassTbl Where Code =@Code_1 )
begin
if exists
(select Code from PassTbl Where Code =@Code_1 and Pass=@Pass_2)
begin
Select CustName from AppMain Where Code =@Code_1 ORDER BY code
end
end
else
begin
select CustName from AppMain Where Code=@Code_1 and Pass=@Pass_2 order by Code
end


It works fine, but it TAKES TIME to execute. Can we simplify it so that it would response soon.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-05 : 13:56:22
seems like what you need is this


CREATE PROCEDURE [dbo].[FindUser]
(@Code_1 [numeric](9)=null,
@Pass_2 [nvarchar](50))=null

AS
select CustName from AppMain
Where (Code=@Code_1 or @Code_1 is null)
and (Pass=@Pass_2 or @Pass_2 is null)
GO
Go to Top of Page

ravininave
Posting Yak Master

111 Posts

Posted - 2009-10-06 : 06:51:53
No, you are not geting my problem. Actually Complete data is alredy in AppMast Table which updates from offline software. Already there is a password and id field. If user will change his password online then it will overwrite on next offline update. for that I've created a passtbl. I've to find if entered id exists in passtbl, if exists check password, if found find name from appmast. The logic is as follows.

Check ID in PassTbl
if found then
find entered password is correct
if correct then
find name from appmast
endif
else
find name from appmast where id=entered id and password =entered password
endif

Go to Top of Page
   

- Advertisement -