0

I'm trying to update SQL data but it contains ' so I get errors.

The SQL statement looks like this:

UPDATE SystemConfiguration
SET    HeaderScript = '<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],' 
WHERE  ID = 1

I tried to replace the quote with " but I get error. I also tried without quote I get error as well.

Any suggestions.

Dale K
  • 25,246
  • 15
  • 42
  • 71
jimm
  • 1
  • 1

1 Answers1

0

You need to double the single quotes to escape them:

UPDATE SystemConfiguration
SET    HeaderScript = '<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({''gtm.start'': new Date().getTime(),event:''gtm.js''});var f=d.getElementsByTagName(s)[0],' 
WHERE  ID = 1