1写了一个数据库的连继ID号(格式:xxxx000001)CREATE PROCEDURE P_GetHId 
 2写了一个数据库的连继ID号(格式:xxxx000001)(
 3写了一个数据库的连继ID号(格式:xxxx000001)    @len int,            --长度
 4写了一个数据库的连继ID号(格式:xxxx000001)    @str varchar(10),        --前缀
 5写了一个数据库的连继ID号(格式:xxxx000001)    @tableName varchar(20),     --表名
 6写了一个数据库的连继ID号(格式:xxxx000001)    @tableFild varchar(20)        --字段名
 7写了一个数据库的连继ID号(格式:xxxx000001))
 8写了一个数据库的连继ID号(格式:xxxx000001)AS
 9写了一个数据库的连继ID号(格式:xxxx000001)BEGIN
10写了一个数据库的连继ID号(格式:xxxx000001)SET NOCOUNT ON
11写了一个数据库的连继ID号(格式:xxxx000001)declare @stra varchar(20)
12写了一个数据库的连继ID号(格式:xxxx000001)declare @sql varchar(800)
13写了一个数据库的连继ID号(格式:xxxx000001)
14写了一个数据库的连继ID号(格式:xxxx000001)set @stra='0000000000000000000'
15写了一个数据库的连继ID号(格式:xxxx000001)set @len=@len-len(@str)
16写了一个数据库的连继ID号(格式:xxxx000001)
17写了一个数据库的连继ID号(格式:xxxx000001)set @sql='
18写了一个数据库的连继ID号(格式:xxxx000001)    declare @fId varchar(50)
19写了一个数据库的连继ID号(格式:xxxx000001)    set @fId=''0''
20写了一个数据库的连继ID号(格式:xxxx000001)select top 1 
21写了一个数据库的连继ID号(格式:xxxx000001)    @fId='+@tableFild+' from '+@tableName+'
22写了一个数据库的连继ID号(格式:xxxx000001)order by '+@tableFild+' desc'
23写了一个数据库的连继ID号(格式:xxxx000001)set @sql=@sql+'
24写了一个数据库的连继ID号(格式:xxxx000001)    select '''+@str+'''+left('''+@stra+''','+cast(@len as varchar(2))+'-len(right(
25写了一个数据库的连继ID号(格式:xxxx000001)        @fId,'+cast(@len as varchar(2))+')+1))
26写了一个数据库的连继ID号(格式:xxxx000001)        +cast(right(@fId,'+cast(@len as varchar(2))+')+1 as varchar(50))'
27写了一个数据库的连继ID号(格式:xxxx000001)exec(@sql)
28写了一个数据库的连继ID号(格式:xxxx000001)end
29写了一个数据库的连继ID号(格式:xxxx000001)GO
30写了一个数据库的连继ID号(格式:xxxx000001)

调用 exec P_GetHId  10,'PN','表名','字段名'   得到结果为 PN00000001 开始递增

相关文章:

  • 2022-01-22
  • 2021-12-27
  • 2021-06-06
  • 2022-12-23
  • 2021-07-17
  • 2021-07-15
  • 2022-12-23
  • 2021-05-01
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2021-12-24
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案