fissehab / T_SQL

Microsoft: DAT201x Querying with Transact-SQL from edx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Insert Sales Order Script

schwaggs opened this issue · comments

commented

The original query was

DECLARE @___ datetime = GETDATE();
DECLARE @___ datetime = DATEADD(dd, 7, GETDATE());
DECLARE @___ int = 1;

INSERT INTO SalesLT.SalesOrderHeader (OrderDate, ___, ___, ShipMethod)
VALUES (@OrderDate, @DueDate, @CustomerID, ___);

PRINT SCOPE_IDENTITY();

You have replaced PRINT SCOPE_IDENTITY(); with
PRINT @orderID;

And you have added several lines that are not necessary.

The correct script is

DECLARE @OrderDate datetime = GETDATE();
DECLARE @DueDate datetime = DATEADD(dd, 7, GETDATE());
DECLARE @CustomerID int = 1;

INSERT INTO SalesLT.SalesOrderHeader (OrderDate, DueDate, CustomerID, ShipMethod)
VALUES (@OrderDate, @DueDate, @CustomerID, 'CARGO TRANSPORT 5');

PRINT SCOPE_IDENTITY();