易截截图软件、单文件、免安装、纯绿色、仅160KB

简单的sql登录和注册存储过程

 首先我建好了一张用户表表中有俩个字段 一个是账号,一个是密码当然这里我写的知识简单的登录很注册,
表明 users 用户表
字段 accountnum  varchar(50) --表示账号
        password     varchar(50) --表示密码
登录存储过程
create proc use_login
(
@accountnum varchar(50),
@password varchar(50),
@message  varchar(50) output

as
  if exists(select * from users where accountnum=@accountnum and  password=@password)
   set @message='登录成功'
 else  if  exists(select * from users where accountnum=@accountnum )
   set @message='密码错误'
 else if exists(select * from users where password=@password)
  set @message='用户名错误'
else
  set @message='用户名和密码都错误'
declare @msg as varchar(50)
exec use_login 'text','text',@msg output
print @msg
注册存储过程
create proc use_registration
(
@accountnum varchar(50),
@password varchar(50),
@message  varchar(50) output
)
as
  if exists(select * from users where accountnum=@accountnum)
   set @message='该用户已经存在'
 else
    begin
     insert into users values(@accountnum,@password)
     set @message='恭喜您,可以注册该用户'
  end 
  declare  @msg as varchar(50)
 exec use_registration 'text','text',@msg output
print @msg
上面再执行存储过程的时候 要打印所要显示出来的信息用的是print 也可以用select
 


相关文档:

sql 多表关联查询

 create database example
use example
create table major
(
 spno varchar(10) primary key not null,
 spname varchar(20) not null
 )
 create table student
(
 sno varchar(10) primary key not null,
 sname varchar(10) not null,
 ssex varchar(2) not null, ......

case语句在SQL中的使用方法

Case具有两种格式。简单Case函数和Case搜索函数。
--简单Case函数
CASE sex
WHEN '1' THEN '男'
WHEN '2' THEN '女'
ELSE '其他' END
--Case搜索函数
CASE WHEN sex = '1' THEN '男'
WHEN sex = '2' THEN '女'
ELSE '其他' END
这两种方式,可以实现相同的功能。简单Case函数的写法相 ......

SQL截取字符串

SQL截取字符串
SUBSTRING
返回字符、binary、text 或 image    表达式的一部分。有关可与该函数一起使用的有效Microsoft SQL Server 数据类型的更多信息,请参见数据类型。   
语法
SUBSTRING      (      expression  & ......

直接执行SQL命令

标签:数据访问     ADO.NET
    直接执行SQL命令     执行面向集合的操作( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号