mistake in sql statement [closed] - sql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to insert data into a table.
This is my SQL statement:
INSERT INTO Employee.dbo.Humanresources (NationalIDNumber, JobTitle, BirthDate, Gender, Hiredate)
VALUES ('131456714','Finanace Manger', '1968-06-17', ' M','2019-05-15'),
('154236172', 'Data Analyst' , '1970-01-14', 'F','2006-04-18'),
('207126133', 'Assistant Manager', '1989-11-15', 'M','2016-07-19'),
('319327624', 'Team Laed', '1991-12-01', ' F',' 2016-06-25')
but I'm getting an error:
Msg 8152, Level 16, State 4, Line 36
String or binary data would be truncated
Please let me know what I did wrong

Is Hiredate a date/datetime field or a 10-character string? If it's a 10-character string, it looks like you have a leading space in the last value shown above. You're also missing the final closing parentheses.

Related

Dash in SQL Record [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
I am trying to insert records into my table but keep getting an error due to the dash (Invalid column name 'NJB572'), how can I go about this? I have 2 columns in this table, both VARCHAR.
INSERT INTO dbo.Inventory VALUES
(131-NJB572, 'BROOM')
(PTI-I20, '9/16 IRONWORKERS')
(PTI-I16, '13/16" PUNCH');
You can use quotes to wrap the column names.
Try,
INSERT INTO dbo.Inventory VALUES
('131-NJB572', 'BROOM')
,('PTI-I20', '9/16 IRONWORKERS')
,('PTI-I16', '13/16" PUNCH');

I'd like to insert any value using 'insert into' but it doesn't work. What is "Column not found error"? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I created table "member". It has two columns name, id and no values. And I'm trying to insert value "spring" into column name!
But It doesn't work...Can anybody help me please?
I wrote like this:
insert into member(name) values("spring");
error is:
Column "spring" not found; SQL statement:
insert into member(name)
values("spring") [42122-200] 42S22/42122
You should use single quotes for your String/Varchar values.
Try this query:
insert into member(name) values('spring');

Postgres Error : syntax error at or near "(" [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am getting this error
ERROR: syntax error at or near "("Position: 65```
for the following query
insert into Employee(no,name,phone) values ((1,Kenit,999999999)(2,Kenit,999999999)(3,Kenit,999999999)(4,Kenit,999999999)(5,Kenit,999999999)(6,Kenit,999999999))
Probably you need commas between paranthesis for each record. And "Kenit" should be in quotes
insert into Employee(no,name,phone) values ((1,'Kenit',999999999),
(2,'Kenit',999999999),(3,'Kenit',999999999),(4,'Kenit',999999999),
(5,'Kenit',999999999),(6,'Kenit',999999999))
Try googling.
Source: https://www.sqlservertutorial.net/sql-server-basics/sql-server-insert-multiple-rows/
INSERT INTO table_name (column_list)
VALUES
(value_list_1),
(value_list_2),
...
(value_list_n);
INSERT INTO Employee (no,name,phone) VALUES ((1,Kenit,999999999),(2,Kenit,999999999),(3,Kenit,999999999),(4,Kenit,999999999),(5,Kenit,999999999),(6,Kenit,999999999));
happy to help
also: phone numbers should be saved in strings, as well as your names. so adding quotation marks helps not only in readability of the code it gives required LOGIC:
example:
...('asdf', 123, '+8920841209')

Using "is not NULL" command on SQL Server is giving me "Msg 102, Level 15, State 1" error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Here's the code I'm using:
SELECT [Año],
[Producto],
ROUND(SUM(Tareas),0) as 'Tareas'
FROM [rstudio].[dbo].[siembra_rd]
WHERE [Año] not in(2021), Tareas is not null
GROUP BY [Año], [Producto]
The issue is the comma, not the boolean expressions. Presumably, you intend one of the following:
WHERE [Año] not in (2021) AND Tareas is not null
or:
WHERE [Año] not in (2021) OR Tareas is not null

sqlerror help please [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
insert into dbo.leerlingen
('1',
'Reduan de Boer',
'postweg12',
'4589 vb',
'zelhem',
'23841')
when i type this in i get this error can anyone help me please
Msg 102, Level 15, State 1, Line 7 Incorrect syntax near ')'.
You are missing the values keyword to introduce the list of values to insert:
insert into dbo.leerlingen values('1', 'Reduan de Boer', 'postweg12', '4589 vb', 'zelhem', '23841')
--^--> here
Note that it is a good practice to enumerate the columns that you want to insert into: this makes the query easier to read to someone who does not know your table structures. Also, if new columns are added that are nullable, you don't need to modify the query.
insert into dbo.leerlingen(id, name, ...) --> enumerate all target columns here
values('1', 'Reduan de Boer', 'postweg12', '4589 vb', 'zelhem', '23841')
Finally: some of your values look like numbers - if they are, then you should not surround them with single quotes (which are typically meant for strings). This makes the intent more obvious, and avoids the need for implicit conversion on database side.