3
Next I have to do a survey and implement a query in the database using Merge
and I have to do it using one of the scripts used in class.
The problem is that when I run the script the following error in insert
and the table ends up being empty.
Order table
CREATE TABLE pedido (nr_pedido numeric(5) NOT NULL,
dt_pedido date, nr_mesa numeric(4));
Insert
INSERT INTO pedido VALUES (1, GETDATE(), 527),
(2, '10/10/2009', 632),
(3, '21/05/2009', 606),
(4, '26/06/2009', 970),
(5, '05/05/2009', 606),
(6, '13/11/2009', 527),
(7, '01/03/2005', 181),
(8, '09/04/2010', 181);
After running the Insert the following error message appears:
Msg 242, Level 16, State 3, Line 67 The Conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.
The correct date format is
AAAA-MM-DD
, that is to say,ano-mês-dia
– Marconi
I made a Fiddle! A little more in the documentation: Date and time data types
– Marconi
In addition to what was mentioned, you can change in your user who is logging into the database the default language. So it will accept the insertion of values in this format
– Aprendiz