i have a query
declare @str as varchar(MAX)= '12,145,1598,1,5';
insert into rdmapping (itemid, rdid) values((Select value From String_Split( @str, ',')),100)
and getting an error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Jignesh KumarPosted Nov 9, 2022, 9:18 AM
Hi Grisma,
You are using sub query in insert statement which will return multiple row. multiple rows will not allow in single column insert due to that its throwing error,
Try this way you can achieve your stuff,
Garima BansalPosted Nov 9, 2022, 9:53 AM
thanks Jignesh Kumar
this works,
but if empty string enter then what will be the condition apply
declare @str as varchar(MAX)= ' ';
insert into rdmapping (itemid, rdid)
Select value as itemid, 100 as rdid From String_Split( @str, ',')
select * from rdmapping