六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 175|回复: 0

三种方法:增加一个自动增长的列

[复制链接]

升级  1.33%

12

主题

12

主题

12

主题

秀才

Rank: 2

积分
52
 楼主| 发表于 2013-2-8 00:32:28 | 显示全部楼层 |阅读模式
--eg1:表里增加字段CREATE TABLE t7(id int IDENTITY(100,1));--eg2:--自动增长的函数 create   function   iden()     returns   int     as     begin         declare   @a1   int         set   @a1   =   1         while   exists(select   *   from   table_name   where   id=@a1)             set   @a1   =   @a1   +   1         return   @a1     end --eg3: 虚拟表select   identity(int,1,1)   kk,*   into   #t   from   T select   #t<style type="text/css">.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }</style>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表