views:

57

answers:

2

I'm not very skilled with regex, I was wondering if it was possible to use a regular expression to transform a string like

insert into tblTest (id,title,col1,col2) values (1,'test','test1','test2')

into

update tblTest set title='test',col1='test1',col2='test2' where id=1

btw, the insert query will not be always like the one I've written in the example, but the first id it will be always present

thanks in advance

+1  A: 

That would be possible with regex if and only if the insert query always had the same number of values. Since it doesn't, no, it's not.

chaos
A: 

You mentioned T-SQL so you could use MERGE on SQL Server 2008 to capture an "UPSERT" type command to avoid transformation or having 2 queries...?

gbn
i have two distinct queries, i think i'll have to write a little script to do this work :) thanks