Update 表名 set AA=left(AA,2)+','+substring(AA,3,2)+','+substring(AA,5,2)+','+right(AA,len(AA) -6)
------------------------------
首先我们明确一个概念,你所说的“插入”指的是在数据表中生成新的记录呢,还是指在字段AA中插入逗号?如果是后者,那么就是数据表的修改操作。
如果是前者,请说明你想把字段AA加入逗号后,插入到哪个表里,包括表名和字段名。
插入方式:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_TABLE1
(
field1 int NOT NULL IDENTITY (1, 1),
field3 float(53) NULL,
field2 nvarchar(50) NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_TABLE1 ON
GO
IF EXISTS(SELECT * FROM dbo.TABLE1)
EXEC('INSERT INTO dbo.Tmp_TABLE1 (field1, field2)
SELECT field1, field2 FROM dbo.TABLE1 TABLOCKX')
GO
SET IDENTITY_INSERT dbo.Tmp_TABLE1 OFF
GO
DROP TABLE dbo.TABLE1
GO
EXECUTE sp_rename N'dbo.Tmp_TABLE1', N'TABLE1', 'OBJECT'
GO
COMMIT
select
substring('abcdefghi',1,2)+','+
substring('abcdefghi',3,2)+','+
substring('abcdefghi',5,2)+','+
substring('abcdefghi',7,len('abcdefghi')-6) sss
-----------------------
sss
---------------------
ab,cd,ef,ghi
(1 row(s) affected)