• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
火星文
博客园    首页    新随笔    联系   管理    订阅  订阅

.net 中如何写简单的存储过程

1.简单的查询存储过程

create procedure SP_GetAllUsers

as

begin

select * from T_User(tableName(表名称))

end

Go

-----------------------

2.根据用户Id来查询用户

create procedure SP_GetUserById

@Id int

as

begin

select * from T_User (tableName) where autoId=@Id;

end

Go

----------------------------------------------------------

3.简单的增加一个用户

create procedure SP_InsertTUser

@Id int,

@UName nvarchar(50),//参数的类型,大小一定要与数据库相对应的字段类型相同

@UAge int,

@UGender char(2)='男'//给定一个默认值

as

begin

insert into T_User(tableName) values(@id,@UName,@UAge,@Gender)

end

Go

注意:procedure 可以简写 proc 只写前四位就OK

posted @ 2011-06-07 22:38  火星文  阅读(311)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3