Evans M. Johnz
Evans M. Johnz

Reputation: 3

How can i use both SELECT and INSERT IN SQL at the same time?

I want to use the Production.Product table to return product name, color and list price for each product. For the color column, where there is NULL, replace it with the string Unknown.

Upvotes: 0

Views: 450

Answers (3)

Dino Liu
Dino Liu

Reputation: 510

If you just want to select color with 'Unknow'

you could use IsNull to replace the Null value select name, IsNull(color,'Unkown') as color from Production.Product Its another way to thinking your problem.

Upvotes: 2

huMpty duMpty
huMpty duMpty

Reputation: 14460

SELECT productname, ISNULL(color,'Unknown') as color,listprice 
FROM Production.Product

Upvotes: 0

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520878

I think you just a single UPDATE statement here:

UPDATE Production.Product
SET color = 'Unknown'
WHERE color IS NULL

Upvotes: 1

Related Questions