我正在尝试将数据从一个OLEDB连接传输到另一个OLEDB。 SSIS和SQL Server都是2008 R2。我想使用变量来加载每年的数据(2014年,2015年等)。源代码中的SQL查询是
DECLARE @year int set @year = ?
SELECT [ServiceActivities]
,[ServiceID]
,[ClientID]
,[WorkerID]
,[CostCode]
,[ProviderID]
,[CostUnit]
,[Units]
,[OccurrenceDate]
FROM [dbo].[PlannedAppointmentsView]
WHERE datepart (yy, OccurrenceDate) = @year
答案 0 :(得分:1)
Try to avoid declaring a variable, just place the ?
in the direct place that you need to pass a parameter.
SELECT [ServiceActivities]
,[ServiceID]
,[ClientID]
,[WorkerID]
,[CostCode]
,[ProviderID]
,[CostUnit]
,[Units]
,[OccurrenceDate]
FROM [dbo].[PlannedAppointmentsView]
WHERE datepart (yy, OccurrenceDate) = ?
If it still doesn't working, then you must follow the suggestion given to you in this error message.
Just Create a variable (ex: strQuery
) of type String
, go to the Properties Tab, change the Evaluate as expression
property to True, and assign the a similar expression to this variable:
"SELECT [ServiceActivities]
,[ServiceID]
,[ClientID]
,[WorkerID]
,[CostCode]
,[ProviderID]
,[CostUnit]
,[Units]
,[OccurrenceDate]
FROM [dbo].[PlannedAppointmentsView]
WHERE datepart (yy, OccurrenceDate) = " + (DT_WSTR,50)@[User::year]
after that in the OLEDB Source select SQL command from variable
option and choose this variable
答案 1 :(得分:1)
You whould just write like this
function checkIsIE() {
var isIE = false;
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
isIE = true;
}
if (isIE) // If Internet Explorer, return version number
{
kendo.ui.Window.fn._keydown = function (originalFn) {
var KEY_ESC = 27;
return function (e) {
if (e.which !== KEY_ESC) {
originalFn.call(this, e);
}
};
}(kendo.ui.Window.fn._keydown);
var windowBrowser = $("#windowBrowser").kendoWindow({
modal: true,
id: 'dialogBrowser',
visible: false,
width: "40%",
title: "Thông báo",
scrollable: false,
resizable: false,
deactivate: false,
position: {
top: 100,
left: '30%'
}
}).data('kendoWindow');
var html = '<br /><div style="width:100%;text-align:center"><p style="color:red;font-weight:bold">Please use the browser below to use the tool</p>';
html += '<img src="/Scripts/IPTVClearFeePackage_Box/Images/firefox.png"/>';
html += ' <img src="/Scripts/IPTVClearFeePackage_Box/Images/chrome.png" />';
html += ' <img src="/Scripts/IPTVClearFeePackage_Box/Images/opera.png" />';
html += '<hr /><form><input type="button" class="btn btn-danger" value="Đóng trình duyệt" onclick="window.close()"></form><div>';
windowBrowser.content(html);
windowBrowser.open();
$("#windowBrowser").parent().find(".k-window-titlebar").remove();
}
else // If another browser, return 0
{
return false;
}
}
And then press declare @Year int = ?
button and select your desired parameter. Then it will work.
But the right way to do it, is like @Hadi writes in his first comment.