![](/img/trans.png)
[英]How to use a variable defined outside of a select statement within a select statement
[英]How to use variable in select statement?
假設包含頂部行數的變量被命名為@[User::TopCount]
創建一個字符串類型的變量(例如: @[User::strQuery]
),將其屬性EvaluateAsExpression
設置為True
。 並分配以下表達式:
"SELECT TOP " + (DT_WSTR,10)@[User::TopCount] + " * FROM table"
在數據流任務中添加一個 OLEDB 源並將訪問模式設置為來自變量的 SQL 命令並使用@[User:strQuery
變量作為源。
declare @numrows int = 5
select top (@numrows) * from MyTable
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.