日期:2014-05-18  浏览次数:20358 次

求高手
能不能用缺省實現插入數據時對一個列自動生成,格式是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;