You could do the following steps:
1) Create a split function for your comma separated string:
CREATE FUNCTION [dbo].[Split] (
@InputString VARCHAR(8000),
@Delimiter VARCHAR(50)
)
RETURNS @Items TABLE (
Item VARCHAR(8000)
)
AS
BEGIN
IF @Delimiter = ' '
BEGIN
SET @Delimiter = ','
SET @InputString = REPLACE(@InputString, ' ', @Delimiter)
END
IF (@Delimiter IS NULL OR @Delimiter = '')
SET @Delimiter = ','
DECLARE @Item VARCHAR(8000)
DECLARE @ItemList VARCHAR(8000)
DECLARE @DelimIndex INT
SET @ItemList = @InputString
SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
WHILE (@DelimIndex != 0)
BEGIN
SET @Item = SUBSTRING(@ItemList, 0, @DelimIndex)
INSERT INTO @Items VALUES (@Item)
SET @ItemList = SUBSTRING(@ItemList, @DelimIndex+1, LEN(@ItemList)-@DelimIndex)
SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
END
IF @Item IS NOT NULL
BEGIN
SET @Item = @ItemList
INSERT INTO @Items VALUES (@Item)
END
ELSE INSERT INTO @Items VALUES (@InputString)
RETURN
END
2) Create a procedure that receives as parameter the comma separated string. In this example I'm using your fixed string but you should modify this to make it work with a parameter.
Note: I'm taking in consideration that your destination table has always 3 columns and that the comma separated string has a length of a multiple of 3 always... You must adapt the procedure if this change...
/* Get the length of the comma separated string */
DECLARE @ITEM_COUNT INT
SELECT @ITEM_COUNT = COUNT(*) FROM
(
SELECT item
FROM Split('"AccountType","contains","Customer","Balance","equals",250,"FirstName","like","John"',',')
) N
declare @x int
set @x = 1
/* Insert in your table every 3 columns... */
WHILE (@x < @ITEM_COUNT)
BEGIN
insert into test
select /* pivoting the sub-query */
fieldname = max(case when seq = @x then item end),
fieldcondition = max(case when seq = @x + 1 then item end),
fieldvalue = max(case when seq = @x + 2 then item end)
from
(
SELECT item
,row_number() OVER (ORDER BY (SELECT 1)) AS seq
FROM Split('"AccountType","contains","Customer","Balance","equals",250,"FirstName","like","John"',',')
) a
set @x = @x + 3
END
Hope this helps