Error converting date or time from character string - sql

I want to inserd data to my DB and I have 2 errors:
1)
insert EmployeesInfo
(ID, MartialStatus, BirthDate, [Address], Phone)
values
(1, 'Не женат', '08/15/1970', 'Викторкая 16/7', '(067)4564489'),
(2, 'Женат', '09/09/1985', 'Малинская 15', '(050)0564585'),
(3, 'Не женат', '12/11/1990', 'Победы 16, 145', '(068)4560409'),
(4, 'Не женат', '01/11/1988', 'Антонова 11', '(066)4664466'),
(5, 'Замужем', '08/08/1990', 'Руденко 10, 7', '(093)4334493'),
(6, 'Замужем', '01/10/1994', 'Просвещения 7', '(063)4114141')
go
Error converting date or time from character string.
2)
insert Stocks
(ProductID, Qty)
values
(1, 20),
(2, 10),
(3, 7),
(4, 8),
(5, 9),
(6, 5),
(7, 12),
(8, 54),
(9, 8),
(10, 7)
go
INSERT statement conflict with FOREIGN KEY constraint "FK__Stocks__ProductI__6FE99F9F". The conflict occurred in the database 'InternatShopDB', table 'dbo.Products', column 'ID'.

Error converting date or time from character string.
Use standard datetime formats. Either '19700815' or '1970-08-15'.
INSERT statement conflict with FOREIGN KEY constraint "FK__Stocks__ProductI__6FE99F9F". The conflict occurred in the database 'InternatShopDB', table 'dbo.Products', column 'ID'.
Make sure that every product that is inserted into the stocks table exists in the products table. Unrecognized products will cause an error.

Related

I'm wondering why after running the SQL query I get this error 1241 - what's wrong here?

CREATE TABLE MOROCCO
(
NUM_PER_MANAGE INT ,
MOYEN_RENT DECIMAL (5,2),
GENDER enum ('m','f'),
race varchar (205)
);
INSERT INTO morocco (NUM_PER_MANAGE, MOYEN_RENT, GENDER, race)
VALUES (3, (300, 45), 'm', 'black');
you must specify decimal value as 300.45 not (300, 45):
INSERT INTO MOROCCO (NUM_PER_MANAGE, MOYEN_RENT, GENDER, race)
VALUES (3, 300.45, 'm', 'black');
and if you are using mysql in linux then you should use the table name in correct case(table name is case sensitive in linux).

Why aren't my columns displaying the correct names and the right amount of characters?

I created my table:
End result:
Any help is appreciated.
I am trying to create a table showing the employee information, but when I used the "insert" command only the information for the second employee appears. Also, the column names are missing and the numbers are incorrect.
Edit
Apologies about the images. I made some updates, but I am still having an issue with the column names and my first row not appearing.
Create table biscoe6
("EmployeeID" "varchar"(11),
"SSN" "varchar"(11),
"fName" "varchar"(12),
"lName" "varchar"(12),
"Position" "varchar"(12),
"Salary" number(10, 2),
"PhoneNum" "char"(12));
insert into biscoe6 ("EmployeeID", "SSN", "fName", "lName", "Position", "Salary", "PhoneNum")
values (null, null, null, null, null, null, null);
values (100, '111-11-0607', 'John', 'Smith', 'Manager', 35000.75, '800-350-0000');
values (200, '333-22-0607', 'John', 'Jones', 'Associate', 25000.00, '202-666-0000');
values (300, '444-444-0607', 'Sally', 'Smith', 'Manager', 46500.00, '303-999-0000');
values (400, '111-11-2102', 'Randy', 'Johnson', 'Intern', 36900.00, '205-654-0000');
I think the first insert-values is working, but the second values does not have a corresponding insert and it is being treated as a simple select-values. The results you see is from the sole values.
You are making a basic mistake,values must be one time and comma separated values. try this
insert into biscoe6 ("EmployeeID", "SSN", "fName", "lName", "Position", "Salary", "PhoneNum")
values
(100, '111-11-0607', 'John', 'Smith', 'Manager', 35000.75, '800-350-0000'),
(200, '333-22-0607', 'John', 'Jones', 'Associate', 25000.00, '202-666-0000'),
(300, '444-444-0607', 'Sally', 'Smith', 'Manager', 46500.00, '303-999-0000'),
(400, '111-11-2102', 'Randy', 'Johnson', 'Intern', 36900.00, '205-654-0000');

EXPLAIN Failed. 3706: (-3706)Syntax error: expected something between ')' and ','

I've seen this error mentioned on StackOverflow, but not in the context I am using. I am relatively new to Teradata and this behavior is throwing me for a loop. Here is code that works:
INSERT INTO test_table (this, that) VALUES (1, 2);
Here is code that throws the error:
INSERT INTO test_table (this, that) VALUES (1, 2), (3, 4);
This is super confusing to me because the Teradata docs have the following example:
INSERT INTO cities VALUES (2, 'San Jose'), (3, 'Oakland');
Could someone show me what am I missing here? Thanks!
Teradata only allows you to insert one record with a single values. You can see this in the syntax diagram for insert -- there is no "backloop".
Two inserts is a simple workaround:
INSERT INTO test_table (this, that)
VALUES (1, 2);
INSERT INTO test_table (this, that)
VALUES (3, 4);

syntax error while trying to INSERT INTO table with postgres

Here's the link to my table:
http://www.sqlfiddle.com/#!17/07f75
Here is my code, but I am getting syntax errors. I've played with a few things, like adding '' around my varchar data types, even changed the text, but am getting this error currently: ERROR: syntax error at or near "moon’" Position: 76
The syntax error has changed since I changed the text, as well as the position, but the type of error has stayed the same. I thought I understood how to insert data into the table but I am at a loss!
CREATE TABLE spacecrafts (
id integer,
name varchar(15),
launched integer,
country varchar(10),
mission text,
orbitingbody varchar(10),
operating varchar(1),
milesfromearth integer
);
INSERT INTO spacecrafts
VALUES
(1, ‘rocketeer1’, 2018, ‘USA’, ‘reach moon’, ‘mars’, ‘y’, 100000),
(2, ‘rocketer2’, 2015, ‘Brazil’, ‘reach moon’, ‘Jupiter’, ’n’, 303230),
(3, ‘rocketship’, 2014, ‘Germany’, ‘reach Jupiter’, ’n’, 67939380);
if you want to insert string data use ' instead of ’
CREATE TABLE spacecrafts (
id integer,
name varchar(15),
launched integer,
country varchar(10),
mission text,
orbitingbody varchar(10),
operating varchar(1),
milesfromearth integer
);
INSERT INTO spacecrafts VALUES
(1, 'rocketeer1', 2018, 'USA', 'reach moon', 'mars', 'y', 100000),
(2, 'rocketer2', 2015, 'Brazil', 'reach moon', 'Jupiter', 'n', 303230),
(3, 'rocketship', 2014, 'Germany', 'reach Jupiter','test', 'n', 67939380);
sqlfiddle
You have a couple errors. I changed your tick marks ' (key in top left) to a quote ' (key next to enter). Those change with cut & paste sometimes so you may not have done that directly.
The other change is on your third entry you don't have an orbitingbody entry.
INSERT INTO spacecrafts
VALUES (1, 'test', 2018, 'usa', 'reach moon', 'mars', 'y', 100000),
(2, 'rocketer2', 2015, 'Brazil', 'reach moon', 'Jupiter', 'n', 303230),
(3, 'rocketship', 2014, 'Germany', 'reach Jupiter', 'Venus', 'n', 67939380);
Notice I added 'Venus' to the third entry.

What's wrong with this SQL INSERT statement?

I want to insert a certain value into a certain field of five different rows altogether. But whenever I run this query it doesn't get executed. What's wrong with it, and how can I fix it?
INSERT INTO `employee`(`password`) VALUES ('abc') WHERE `id` IN (1,2,3,4,5);
An INSERT can't have a WHERE clause. It looks like you meant to do an update:
UPDATE `employee`
SET `password` = 'abc'
WHERE `id` IN (1,2,3,4,5);
Or perhaps a multi-row insert:
INSERT INTO `employee` (`id`, `password`)
VALUES (1, 'abc'), (2, 'abc'), (3, 'abc'), (4, 'abc'), (5, 'abc');
Also, FYI, you really shouldn't be storing passwords as plain text, which it looks like you may be doing.