且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在sql server 2008中增加标识?

更新时间:2022-05-25 23:03:11

检查链接......并根据需要进行更改..



http://forums.asp.net/t/1608233.aspx [ ^ ]
Check the link..and change according to your need..

http://forums.asp.net/t/1608233.aspx[^]


创建一个生成id的函数



Make a function for genrating id

void Id()
       {
           string query = "select * from POS1 where Warehouse='" + Warehouse.Text + "' order by No";
           DataTable dt = conn.fill(query);
           string id = ""; int ID = 0;
           if (dt.Rows.Count > 0)
           {
               int ctr = dt.Rows.Count - 1;
               id = dt.Rows[ctr]["NO"].ToString();
               ID = int.Parse(id);
               ID++;
               string no =V3W000.ToUpper();
               id = no + "/" + ID;
           }
           else
           {
               string no = V3W000.ToUpper();
               ID = 1;
               id = no+ "/" + ID;
           }
           TextBox.Text = id;

   }


使用一些PL / SQL播放。



使用SQL Server自定义自动生成的序列 [ ^ ]
Play with some PL/SQL.

Custom Auto-Generated Sequences with SQL Server[^]