Skip to content
Advertisement

How to use temp table in SQL Server script?

I have to use some hardcode data in sql script, for this I am using temp table

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)

On line 6, it is showing error as Expecting Id

Is there any simplest way to do this?

Advertisement

Answer

There is no double data type in sql server 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)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement