存储过程_可以一次实现 增删改查多个功能吗? 中间怎样衔接 like: Create Proc AAAas  Insert …… Update……在 Insert  和 Update 之间 应该用神马衔接?这是两个完全不相干的命令 还是不用? 
我做一个东西 必须 每个人的数据库不同 所以每个人在用的时候都是Create一个新的数据库 注册数据库 我就想到了存储过程 用存储过程Create一个数据库and其中的所有表 想问一下 该怎么衔接…… 就如上边 Insert和Update中间加东西还是不加东西?

解决方案 »

  1.   


    --定义表或是创建表
    declare @table table(id int)
    --插入
    insert into @table select 5 union all select 6
    --查看
    select * from @table
    /*
    id
    -----------
    5
    6
    */
    --更新
    update @table set id=7 where id=6
    --查看
    select * from @table
    /*
    id
    -----------
    5
    7
    */
    --删除
    delete from @table where id=5
    --查看
    select * from @table
    /*
    id
    -----------
    7
    */
    你可以直接复制运行看结果...