Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to insert a row into my table using sql query INSERT INTO

I am trying to insert a new row into my database using an INSERT INTO SQL query. I am not sure what I am doing wrong as I am not the more experienced programmer.

I am trying to add the integer value 1 to the column Question Type when the button is pressed. My primary key increments automatically so that shouldn't be a problem as all of the other columns can be NULL.

INSERT INTO dbo.Questions (Question Type)
VALUES (1)

When I press OK to this query an error displays saying :

An error occurred while trying to create the parameterized query:

Error in list of function arguments: 'Type' not recognized. Incomplete parameters or column list. Unable to parse query text.

This is the code for the table I am trying to add to:

CREATE TABLE [dbo].[Questions] (
[QuestionID]     INT           IDENTITY (1, 1) NOT NULL,
[Actual answer]  NVARCHAR (50) NULL,
[Question Space] NVARCHAR (50) NULL,
[Question Type]  INT           NULL,
PRIMARY KEY CLUSTERED ([QuestionID] ASC)
);
like image 222
mot375 Avatar asked Dec 30 '25 13:12

mot375


2 Answers

Try this.. If the column name has White Space, then the entire column name should be enclosed using Square Brackets ([]).

INSERT INTO dbo.Questions ([Question Type])
VALUES (1)

This is for SQL server... if it is MySQL then use ("") or (``)

like image 119
Ambareesh Surendran Avatar answered Jan 01 '26 01:01

Ambareesh Surendran


you not allowed to use spaces between column names. either use identifier with double quotes or square braces."" OR []

INSERT INTO dbo.Questions ("Question Type")
VALUES (1)
like image 40
Ameya Deshpande Avatar answered Jan 01 '26 03:01

Ameya Deshpande



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!