如何在SQL Server脚本中使用临时表?

如何在SQL Server脚本中使用临时表?,sql,sql-server,temp-tables,Sql,Sql Server,Temp Tables,我必须在sql脚本中使用一些硬代码数据,为此我使用临时表 CREATE TABLE #Temp ( [Type] INT, StartDate DATETIME, EndDate DATETIME, InterestRate DOUBLE ); INSERT INTO #Temp VALUES (1, '2015-07-01', '2017-05-01', 27), (1, '2017-05-02', '2017-06-30', 25.71)

我必须在sql脚本中使用一些硬代码数据,为此我使用临时表

CREATE TABLE #Temp
(
    [Type] INT,
    StartDate DATETIME,
    EndDate DATETIME,
    InterestRate DOUBLE
);

INSERT INTO #Temp 
VALUES (1, '2015-07-01', '2017-05-01', 27),
       (1, '2017-05-02', '2017-06-30', 25.71)
在第6行,它将错误显示为
预期Id


有什么最简单的方法可以做到这一点吗?

sql server中没有
double
数据类型
use
decimal

CREATE TABLE #Temp
(
    [Type] Int,
    StartDate DateTime,
    EndDate DateTime,
    InterestRate decimal
);

Insert Into #Temp Values 
(1,'2015-07-01','2017-05-01',27),
(1,'2017-05-02','2017-06-30',25.71)

SQL
不支持
DOUBLE
,您可以使用
float
decimal
代替
DOUBLE

CREATE TABLE #Temp
(
    [Type] Int,
    StartDate DateTime,
    EndDate DateTime,
    InterestRate decimal
);

Insert Into #Temp Values 
(1,'2015-07-01','2017-05-01',27),
(1,'2017-05-02','2017-06-30',25.71)

您应该使用
十进制
,但需要给出
刻度
精度
。默认值为
0
。这对利率来说不是很有用。看


另外,。它们被称为
float
real
。出于财务目的,我认为
decimal
/
numeric
是一个更好的选择。

@BlackCat。您可能需要重新考虑您接受的答案,因为它没有按照您的意愿存储数据。
CREATE TABLE #Temp (
    [Type] INT,
    StartDate DATETIME,
    EndDate DATETIME,
    InterestRate DECIMAL(10, 6)
);

INSERT INTO #Temp 
    VALUES (1, '2015-07-01', '2017-05-01', 27),
           (1, '2017-05-02', '2017-06-30', 25.71);