目瞪口呆在sql中声明一个变量

时间:2017-01-25 10:23:56

标签: sql variables declaration

我已经全面搜索了互联网,试图看看我做错了什么。我无休止地得到了"声明:语法"错误无论代码在哪里我都移动了声明。我已经尝试过,有没有@符号和分号,认为这是与C ++不同的东西。我读过的所有指南都说这应该有效,所以也许这里有人可以告诉我出了什么问题?

BEGIN TRANSACTION;

DECLARE @clID INT;
CREATE TABLE CLAIM(claimID, repDate, lossDate, claimNo, claimStat);
INSERT INTO CLAIM VALUES(1, '2016-10-1', '2016-10-1', 1, 'Open');
INSERT INTO CLAIM VALUES(2, '2016-10-1', '2016-10-1', 2, 'Open');

CREATE TABLE EXPOSURE(expID, claimID, coverage, claimEx, expStat);
INSERT INTO EXPOSURE VALUES(1, 2, 'BI', 'U152', 'Open');
INSERT INTO EXPOSURE VALUES(2, 2, 'PD', 'U152', 'Open'); 

CREATE TABLE RESERVELINE(resLineID, expID, claimID, covID, IP);
INSERT INTO RESERVELINE VALUES(1, 1, 2, 'BI', 02);
INSERT INTO RESERVELINE VALUES(1, 3, 3, 'CDL', 01);

CREATE TABLE RESULTS(claimID);
COMMIT; 

INSERT INTO RESULTS
SELECT claimID FROM CLAIM WHERE repDate<'2016-10-3';
SELECT * FROM RESULTS;

--Must FIRST query first table with Date()

谢谢你们。

0 个答案:

没有答案