I'm trying to do the following in Microsoft SQL Server:
CREATE开发者_Go百科 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:
N' ..... <xsd:pattern value="\w+([-+.''] ..... '
From Constants:
If a character string enclosed in single quotation marks contains an embedded quotation mark, represent the embedded single quotation mark with two single quotation marks.
精彩评论