2

在 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,'''', '''''')

我该如何纠正这个错误?

4

1 回答 1

3

怎么样:

SELECT DISTINCT REPLACE(City,'''', '''''') FROM Person.Address
WHERE City like '%''%'
于 2012-03-20T19:14:05.773 回答