我在我的數據庫中有很多表,我正在收集下面的代碼的計算值,並希望將這些值插入到其他表中。我使用SELECT INTO方法,但數據庫告訴我「關鍵字INTO行附近的語法不正確......」。我相信有一些我失蹤,但不知道在哪裏。代碼看起來很好。這是我的代碼。任何幫助,將不勝感激。SELECT INTO advanced
SELECT (second.[cdate][email protected]) AS 'Date', first.[machine_no] AS 'No',
tbl_machines.[manufacturer] As 'Manufacturer',
tbl_machines.[type] As 'Machine Type',tbl_machines.[game_name] AS 'Game Name',
tbl_machines.[accounting_denomination] AS 'Denom',
(second.[turnover])-(first.[turnover]) AS 'Turnover',
(second.[total win])-(first.[total win]) AS 'Total win',
(second.[games played])-(first.[games played]) AS 'Games Played',
(second.[Bill in])-(first.[Bill in]) AS 'Bill In',
(second.[credit in])-(first.[credit in]) AS 'Credit IN',
(second.[cancel credit])-(first.[cancel credit]) AS 'Cancel Credit',
tbl_rate.[euro] AS 'euro rate',
tbl_rate.[dollar] AS 'dollar rate'
INTO tbl_daily
FROM tbl.meter first,tbl.machines,tbl_rate
INNER JOIN tbl_meter second ON first.[Machine_No] = second.[Machine_No]
AND
tbl_machines.[local_no]=first.[machine_no]
WHERE first.[cDate] = @StartDate
AND second.[cDate] = @EndDate
AND tbl_rate.[cdate][email protected];
好吧,我用INSERT INTO語法,一切都很順利,但現在我有問題,日期時間。當我使用下面的sql命令時,我收到錯誤,它說「無法將數據類型位轉換爲日期時間」我試過Martin的轉換方法,但它是一樣的。
我的代碼是
INSERT INTO tbl_daily SELECT tbl_machines.[ID] AS 'ID', (second.[cdate][email protected]) AS 'CDate', first.[machine_no] AS 'No',
tbl_machines.[manufacturer] As 'Manufacturer',
tbl_machines.[type] As 'MachineType',
tbl_machines.[game_name] AS 'GameName',
tbl_machines.[accounting_denomination] AS 'Denom',
(second.[turnover]-first.[turnover]) AS 'Turnover',
(second.[total win]-first.[total win]) AS 'Totalwin',
(second.[games played]-first.[games played]) AS 'GamesPlayed',
(second.[credit in]-first.[credit in]) AS 'CreditIN',
(second.[Bill in]-first.[Bill in]) AS 'BillIn',
(second.[cancel credit]-first.[cancel credit]) AS 'CancelCredit',
tbl_rate.[euro] AS 'eurorate',
tbl_rate.[dollar] AS 'dollarrate'
FROM tbl_meter first,tbl_machines,tbl_rate
INNER JOIN tbl_meter second ON first.[Machine_No] = second.[Machine_No] AND tbl_machines.[local_no]=first.[machine_no]
WHERE first.[cDate] = @StartDate AND second.[cDate] = @EndDate AND tbl_rate.[cdate][email protected];
這是什麼SQL語言? – 2010-07-17 18:38:42