【发布时间】:2019-06-30 01:13:37
【问题描述】:
我有一个接收存储 id 参数的存储过程。我需要将该变量添加到 openquery tsql 脚本中我无法做到这一点。在我的代码中查看它说@var 这就是变量需要工作的地方
我试图引用这个https://support.microsoft.com/en-us/help/314520/how-to-pass-a-variable-to-a-linked-server-query,但我无法让它工作
SELECT x.*
FROM (
SELECT tl.title_log_sts_cd
,tl.ro_vin
,tl.ro_store_id
,ll.CurrentLoanStatus
,bc.vin
,bc.BorrowerId
,ll.DisplayLoanNumber
,CONVERT(DATE, CONVERT(VARCHAR(10), ll.CreateDateKey, 7)) LoanDate
,CONCAT (
bb.LastName
,','
,bb.FirstName
) CustomerName
,ll.CurrentPrincipalBalanceAmt + ll.CurrentFeeBalanceAmt TotalDue
FROM OPENQUERY(TLXPRD, 'SELECT * FROM TITLE_LOG
WHERE title_log_sts_cd in (''Ready to Send to DMV'', ''Sent to DMV'')
and ro_store_id =@VAR ') AS tl
JOIN EIS.Borrower.Collateral bc WITH (NOLOCK) ON tl.ro_vin = bc.Vin
LEFT JOIN eis.loan.loan ll WITH (NOLOCK) ON ll.BorrowerId = bc.BorrowerId
AND convert(DATE, tl.created_ts) = CONVERT(DATE, CONVERT(VARCHAR(10), ll.CreateDateKey, 7))
LEFT JOIN EIS.Borrower.Borrower BB ON bb.borrowerid = ll.BorrowerId
) AS x
ORDER BY vin
期望从oracle得到一些数据,用tsql加入
【问题讨论】:
-
变量的数据类型是什么?
标签: sql-server tsql openquery