Click here to Skip to main content
15,905,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. My question as said in the title is how to insert only one value into a single column of a table. INSERT statement doesn't seem to suffice since it always does its insertion row by row and fills the rest of the columns with null values.
Thanks in advance.

(P.S. i know dynamic SQL so your answer can include it if you want.)
Posted
Updated 15-Sep-14 19:56pm
v2

1 solution

You cannot insert a single column, only a full row.
If all your columns int the table allow null, you can use a query like this
SQL
INSERT INTO table_name (single_column) VALUES (some_value);


Otherwise you can only update an existing row and this can be done for a single column.
SQL
UPDATE table_name SET single_column = some_value WHERE primary_key = a_value;

(Or a natural key)

Maybe do some reading on your own.
SQL Tutorial[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900