我在Azure数据工厂中有查找活动。我有一个参数";偏移";,其具有初始值5。我想在查找查询中使用参数值作为整数值,但失败了。请提供建议。
原始静态查找查询:
SELECT *
FROM sales.[Customers]
ORDER BY CustomerId OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY
--参数化查找查询:
SELECT *
FROM sales.[Customers]
ORDER BY CustomerId @concat('OFFSET ', pipeline().parameters.offset,' ROWS FETCH NEXT 10 ROWS ONLY')
参数化查找的ADF错误:
A database operation failed with the following error: 'Incorrect syntax near
'@concat'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near
'@concat'.,Source=.Net SqlClient Data
Provider,SqlErrorNumber=102,Class=15,ErrorCode=-2146232060,State=1,Errors=
[{Class=15,Number=102,State=1,Message=Incorrect syntax near '@concat'.,},],'
将整个SQL语句放入表达式中(使用表达式生成器(:
@concat('SELECT * FROM sales.[Customers] ORDER BY CustomerId OFFSET ', pipeline().parameters.offset, ' ROWS FETCH NEXT 10 ROWS ONLY')
您也可以直接调用参数
SELECT *
FROM sales.[Customers]
ORDER BY CustomerId OFFSET @{pipeline().parameters.offset} ROWS FETCH NEXT 10 ROWS ONLY