2

ADO.NET ソースを使用して、ODBC サーバーから SQL にデータを取り込みます。インポートおよびエクスポート ウィザードを使用して、データ フロー タスクを作成しました。

フィールド GPMTADDT>(yesterday date) を持つ新しいレコードを追加する必要があります。たとえば、今日 20121002 の場合、次のクエリは完全に機能します。

SELECT  PARTICIP.* 
FROM PARTICIP
WHERE GPMTADDT > 20121001

私は試した:

SELECT  PARTICIP.* 
FROM PARTICIP
WHERE GPMTADDT > Format(now(),"yyyymmdd")

サーバーは「フォーマット」を列として扱います。変数を作ってみた@date

SELECT  PARTICIP.* 
FROM PARTICIP
WHERE GPMTADDT > @date

再びサーバーは「@」を拒否しました。

Also tried:
SELECT  PARTICIP.* 
FROM PARTICIP
WHERE GPMTADDT > (SELECT MAX PARTICIP.GPMTADDT FROM PARTICIP)

簡単なものが欠けていると確信しています。助けていただければ幸いです。

ありがとうございました!

4

2 に答える 2

1

Have you tried:

SELECT PARTICIP.*
FROM PARTICIP
WHERE GPMTADDT > DATEADD(dd, -1, GETDATE())
于 2012-10-02T21:20:21.743 に答える
0

You haven't mentioned what your data source actually is, but there appear to be several errors in the SQL syntax you've tried. e.g. the first query should have single quotes around the date, the last one should put the argument to MAX() in parentheses etc.

But to try to answer your basic question, ADO.NET sources do not support parameters, unlike OLE DB ones that do. Some possible solutions are:

  1. Don't use a parameter if you can generate the value in the source itself; this is what you are trying to do in your last example and what Jeff has suggested
  2. Use an SSIS expression to set the SqlCommand property of the connection object, together with an SSIS variable (as described here)
  3. As an alternative to #2, use a Script task to build the complete SELECT query, assign it to an SSIS variable, and then use that variable as the SqlCommand value

Personally I would say that option 1 is the easiest but of course not always possible, if the variable isn't accessible from within the source system. 2 and 3 are variations on the same solution, but I prefer 3 because I find writing a script easier than working with expressions.

于 2012-10-02T21:27:50.360 に答える