在SQL Server中,我有这个查询
SELECT DISTINCT City FROM
Person.Address
但是这给了我两个名字像Ville De'anjou的城市(即')
您可以通过此
尝试相同的操作SELECT DISTINCT City FROM
Person.Address
WHERE City like '%''%'
现在,我正在创建一个SSIS包,它正在为每个城市创建文件夹。但是这两个城市的套餐失败并抛出了这个错误
[ADO NET Source [1]] Error: An error occurred executing the provided SQL command: "SELECT AddressID, AddressLine1,PostalCode, City
FROM Person.Address WITH(NOLOCK)
WHERE City = 'Ville De'anjou'". Incorrect syntax near 'anjou'.
Unclosed quotation mark after the character string ' SET FMTONLY OFF;'.
失败,因为这不是正确的查询。
我试过这个但没有运气,而是从名单中删除了这两个城市
SELECT DISTINCT CITY FROM Person.Address
WHERE City like REPLACE(City,'''', '''''')
如何纠正此错误?
答案 0 :(得分:3)
怎么样:
SELECT DISTINCT REPLACE(City,'''', '''''') FROM Person.Address
WHERE City like '%''%'