如何在单个插入查询中插入多个拆分字符串

如何在单个插入查询中插入多个拆分字符串

创建下表

Declare @APS nvarchar(1000)='1,1,1.5,1.791'
,@cluster nvarchar(1000)='0150,0150,001,0382'
,@style nvarchar(1000)='696707-018,696707-018,696707-018,696707-018'


CREATE TABLE #temptable (
ID int IDENTITY (1, 1) NOT NULL ,
stylecolor varchar (500) NOT NULL ,
APSDev varchar (250)  NULL,
ClusterID varchar(1000) Null
)

这里我需要插入值

Insert into #temptable  (stylecolor, ClusterID, APSDev)
select  item  from  [<table name>]. dbo.SplitString(@style,',') 
select  item  from  [<table name>].dbo.SplitString(@cluster,',')
select  item  from  [<table name>]. dbo.SplitString(@APS,',')

收到错误:

The select list for the INSERT statement contains fewer items than the 
insert list. The number of SELECT values must match the number of INSERT 
columns.

相关内容