INSERT INTO @TABLE
Instead of storing static values in a table variable, let's store the result of a query.
Cet exercice fait partie du cours
Writing Functions and Stored Procedures in SQL Server
Instructions
- Declare a
TABLEvariable named@RideDateswith the following columnsRideStartandRideEnd. - Both table variable columns should be
datedata type. SELECTthe unique values ofStartDateandEndDatefrom theCapitalBikeSharetable.CASTthem fromdatetimetodatedata types.- Store the query results in
@RideDates.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
-- Declare @RideDates
___ ___ ___(
-- Define RideStart column
___ ___,
-- Define RideEnd column
___ ___)
-- Populate @RideDates
___ ___ @RideDates(RideStart, RideEnd)
-- Select the unique date values of StartDate and EndDate
SELECT ___
-- Cast StartDate as date
___(___ as date),
-- Cast EndDate as date
___(___ as date)
FROM CapitalBikeShare
SELECT *
FROM @RideDates