我试图包含一个声明语句,引用一个临时表和其他声明语句。它可以单独工作,但是当我添加剩余的declare子句时,我收到错误......
{ request:
{ debugId: 1,
uri: 'https://api.domain.com/path/to/resource',
method: 'GET',
headers:
{ host: 'api.domain.com',
authorization: 'Bearer abc123def456' } } }
答案 0 :(得分:0)
尝试分离表变量创建,如下所示
Startup
而不是
declare @id1 int
declare @id table
(
id int
)
select * from @id
这已在文档中提及:DECLARE (Transact-SQL)
声明表变量时,表变量必须是DECLARE语句中声明的唯一变量。
答案 1 :(得分:0)
在@Dept前面的@baseline_end和delcare之后试试这个分号
declare @meas_enddate datetime,
@meas_startdate datetime,
@enc_startdate datetime,
@enc_enddate datetime,
@activestart datetime,
@activeend datetime,
@baseline_start datetime,
@baseline_end datetime;
declare @Dept as Table (DEPARTMENT_ID numeric(18,0) NOT NULL PRIMARY KEY,
UNIQUE NONCLUSTERED (DEPARTMENT_ID))
INSERT INTO @Dept
SELECT
'100501201'
UNION SELECT '100208501'
UNION SELECT '100302304'