-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpasswordIncriptionAndLogstatus.sql
More file actions
60 lines (50 loc) · 1.11 KB
/
passwordIncriptionAndLogstatus.sql
File metadata and controls
60 lines (50 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
create table userdata
(
id nvarchar(20) primary key,
pwd varbinary(100)
)
create table sesdata
(
sesid int,
useid nvarchar(20) references userdata(id),
logstat bit default 0
)
select * from userdata
select * from sesdata
create proc newuserid @id nvarchar(20),@pwd nvarchar(50), @n int out
as
begin
declare @count int
set @count=(select COUNT(*) from userdata where id=@id)
if(@count >0)
begin
set @n =-1
end
else
begin
insert into userdata values(@id,HASHBYTES('SHA',@pwd))
insert into sesdata values(0,@id,0)
set @n=0
end
end
declare @num int
exec newuserid '2','123456',@n =@num out
select @num
alter proc newuserlogin @id nvarchar(20),@pwd nvarchar(50), @sesno int out
as
begin
declare @count int=-1
set @count=(select COUNT(*) from userdata where id=@id and pwd=HASHBYTES('SHA',@pwd))
if(@count>0)
begin
update sesdata set sesid=sesid+1, logstat=1 where useid = @id
set @sesno=(select sesid from sesdata where useid=@id)
end
else
begin
set @sesno=-1
end
end
declare @num int
exec newuserlogin '2','123456', @sesno=@num out
select @num