带有参数和通配符的T-SQL EXEC到DB2

时间:2017-02-10 14:29:28

标签: sql sql-server parameters db2 wildcard

我有这个代码,它构成了从IBM DB2数据库查询数据的SQL Server 2012存储过程的一部分,但它无法正常工作。

    @Search nvarchar(50) = ''
AS
BEGIN
    SET NOCOUNT ON;

    EXEC('select mbwhlo as Store,
                 mbitno as SKU,
                 mmitds as Description,
                 mwwhnm as StoreName,
                 mbstqt as Qty,
                 SUBSTRING(mbitno, 12, 4) AS Size
          from m3fdbprod.mitbal
          left outer join m3fdbprod.mitwhl on mbcono = mwcono AND mbwhlo = mwwhlo
          left outer join m3fdbprod.mitmas on mbcono = mmcono AND mbitno = mmitno
          where mbcono = 1
            and mbitno = ?
             or mmitds = ?
             or mwwhnm = ?
             or mmitds = ?
          order by mbitno, mbwhlo', '%' + @Search +'%',+'%'@Search+'%',+'%'@Search+'%',+'%'@Search+'%') AT LawsonDR

我收到此消息:

  

' +'

附近的语法不正确

0 个答案:

没有答案