如果我们传递从“Canada,Portugal”转换为“Canada”、“Portugal”的值在子句中,如果在子句“Canada”、“Portugal”中传递硬编码值,则 Sql 查询不起作用
declare @GeographicalLocation varchar(max)
set @GeographicalLocation ='Canada,Portugal'
set @GeographicalLocation = REPLACE(@GeographicalLocation, ',', ''',''')
set @GeographicalLocation = ''''+@GeographicalLocation+'''';
select ContinentName from [ContinentList] where ContinentId in
(select ContinentId from [CountryList] where [CountryName]
in(@GeographicalLocation)and BaseId is Null)