Reputation: 178
I want to insert multiple null values in a sql table.Can some body help in the below query
UPDATE PDetail
SET rText = null AND ctnumber = null AND ptext = null
WHERE rText = 'For help' OR ctnumber = '123654789'
INSERT INTO PDetail (rText,ctnumber,ptext) VALUES (NULL,NULL,NULL)
WHERE rText = 'For help' OR ctnumber = '123654789'
Upvotes: 0
Views: 2318
Reputation: 35343
--here's 50 assuming no constraints...
INSERT INTO PDetail (rText,ctnumber,ptext) VALUES
(
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),
(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL),(NULL,NULL,NULL)
);
This seems really odd though why do you need to insert 50 records of null values?
Upvotes: 0
Reputation: 69554
You need to update values, not insert since you are changing values for already existing records in your table using a where condition in your query. do something as follows ...
UPDATE PDetail
SET rText = null
,ctnumber = null
,ptext = null
WHERE rText = 'For help'
OR ctnumber = '123654789'
Upvotes: 3