Remove a certain value from string which keeps on changing

Posted by user2971375 on Stack Overflow See other posts from Stack Overflow or by user2971375
Published on 2013-11-09T07:56:42Z Indexed on 2013/11/09 9:54 UTC
Read the original article Hit count: 262

Filed under:

I m trying to make a utility to generate a Insert script of sql tables along with relational table.

I got all the values in c#.

Now I want to remove the one column name and its value from the script.most probably the identity column.
Eg.

The string I have (which keeps on changing with table name and varies)

INSERT Core.Customers
([customerId],[customername],[customeradress],[ordernumber])
               Values(123,N'Rahul',N'244 LIZ MORN',2334)

NOW I know I have to remove CustomerId. (sometimes need to be replaces with @somevariable)

Please give me an efficient way how to retrieve customerId value and Deleting column name and value .

Conditions:

  1. insert script length and columns names keep changing.
  2. Method should return the deleted value.
  3. At some point of time customer id can be same as order id. In that case my string.remove method fails.

© Stack Overflow or respective owner

Related posts about c#