I’m trying to do the following in Microsoft SQL Server:
CREATE XML SCHEMA COLLECTION [dbo].[XYZSchema] AS
N'schema content'
GO
The problem is that schema content contains a quote (‘) in a regexp and is breaking the instruction:
N' ..... <xsd:pattern value="\w+([-+.'] ..... '
Is there a way to escape the quote and maintain the correctnes of the regexp, or declare the Expresion of CREATE XML SCHEMA COLLECTION in some other way?
You’re writing a varchar (well, nvarchar) literal. The way to escape single quotes within such a literal is to double them up:
From Constants: