服务器: 消息 170,级别 15,状态 1,行 117 行: 'CASE WHEN ' 附近有语法错误。
EXEC( '
INSERT ' + @Airline + ' (
Departure,
Destination,
FeederRoutingID,
OnlineRoutingID,
InterlineRoutingID,
FeederFareID,
OnlineFareID,
InterlineFareID,
ContractID,
DateFrom,
DateTo,
IsRoundTrip,
Airline)
SELECT t1.a as Departure,t2.a as Destination, '
'CASE WHEN ' + @FeederRoutingID + ' IS NULL THEN NULL ELSE ' ' ' + @FeederRoutingID + ' ' ' END , ' ' ' +
@OnlineRoutingID+ ' ' ', ' +
'CASE WHEN ' + @InterlineRoutingID + 'IS NULL THEN NULL ELSE ' ' ' + @InterlineRoutingID + ' ' ' END , ' ' ' +
'CASE WHEN ' + @FeederFareID + 'IS NULL THEN NULL ELSE ' ' ' + @FeederFareID + ' ' ' END , ' ' ' +
@OnlineFareID+ ' ' ', ' +
'CASE WHEN ' + @InterlineFareID + 'IS NULL THEN NULL ELSE ' ' ' + @InterlineFareID + ' ' ' END , ' ' ' +
@ContractID+ ' ' ', ' ' ' +
@DateFrom+ ' ' ', ' ' ' +
@DateTo+ ' ' ', ' ' ' +
@IsRoundTrip+ ' ' ', ' ' ' +
@Airline + ' ' ' FROM
(
select airportcode As a from
(
select * from zone where zoneNo= ' ' '+ @FeederDep + ' ' ')Z
INNER JOIN ZoneElement ZE ON Z.zoneID=ZE.zoneID
INNER JOIN MST_AirPort A ON A.AirPortID=ZE.AirPortID
) AS t1
CROSS JOIN
(
select airportcode As a from
(
select * from zone where zoneNo= ' ' '+ @Destination + ' ' ')Z
INNER JOIN ZoneElement ZE ON Z.zoneID=ZE.zoneID
INNER JOIN MST_AirPort A ON A.AirPortID=ZE.AirPortID
) AS t2
')
------解决方案--------------------SELECT t1.a as Departure,t2.a as Destination, '+ --很显然这里少了一个+号
------解决方案--------------------EXEC( '
INSERT ' + @Airline + ' (
Departure,
Destination,
FeederRoutingID,
OnlineRoutingID,
InterlineRoutingID,
FeederFareID,
OnlineFareID,
InterlineFareID,
ContractID,
DateFrom,
DateTo,
IsRoundTrip,