当前位置: 代码迷 >> Sql Server >> 求高手解决方案
  详细解决方案

求高手解决方案

热度:46   发布时间:2016-04-27 17:32:48.0
求高手
能不能用缺省實現插入數據時對一個列自動生成,格式是PQ+0001...

------解决方案--------------------
CREATE TABLE [dbo].[Table1] (
[sn] [int] IDENTITY (1, 1) NOT NULL ,
[col1] AS ( 'PQ ' + replicate( '0 ',(10 - len([sn])))) ,
[col2] [char] (10)
)
go
insert into table1(col2)
select 'b '
union select 'c '
go
select * from table1;
  相关解决方案