Dash in SQL Record [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 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');

Related

How to insert this type of date in column [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 10 months ago.
Improve this question
I have column StartDate and i need to insert this date
INSERT INTO Products(StartDate) VALUES(2001-01-01 00:00:00.000)
There but it doesn't work
The problem is that you need single quotes around your literal datetime value.
If the millseconds are added depends on the datatype of the column.
INSERT INTO Products(StartDate) VALUES('2001-01-01 00:00:00.000')

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')

Postgres column doesn't exist error on update [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 3 years ago.
Improve this question
I am trying to run the query below but I am getting an error ERROR: column "test.pdf" does not exist . I dont know why I am getting this error. I search for various links on stackover but none solved my problem like this PostgreSQL query -- column does not exist, Postgres error updating column data. Please help me find the problem.
bill is a type string field in bills table.
update bills
set bill = "test.pdf"
where id=3;
Change the double quotes you have around test.pdf to single quotes.

Give an Alias to a column I've casted as a date [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 7 years ago.
Improve this question
Basically I'm selecting all the rows from a table and stripping the time portion of the date using
CAST(CREATE_DATE AS DATE)
but my results give me the rows I need but the column is unnamed.
How do I give the column a name?
Like this:
Cast(create_date as date) as [Column Name Here]
You can omit the [] if you are not using spaces or reserved words in your column name (which is good practice anyway).