INSERT INTO @TABLE
Instead of storing static values in a table variable, let's store the result of a query.
Este ejercicio forma parte del curso
Writing Functions and Stored Procedures in SQL Server
Instrucciones del ejercicio
- Declare a
TABLE
variable named@RideDates
with the following columnsRideStart
andRideEnd
. - Both table variable columns should be
date
data type. SELECT
the unique values ofStartDate
andEndDate
from theCapitalBikeShare
table.CAST
them fromdatetime
todate
data types.- Store the query results in
@RideDates
.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
-- 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