Sample Header Ad - 728x90

Replace NULLs with value

-1 votes
1 answer
83 views
Here is my temporary table: CREATE TABLE #test123( c1 float, c2 float, c3 float, c4 float, c5 float ); INSERT #test123(c1,c2,c3,c4,c5) VALUES (2,3,NULL,1,2), (2,NULL,NULL,1,2), (2,3,NULL,NULL,2), (NULL,3,NULL,1,NULL), (2,3,NULL,1,2); When I run the following querys to replace all NULLs in the first column INSERT INTO #test123 (c1) VALUES (ISNULL(c1,0)); or INSERT INTO #test123 (c1) SELECT CASE WHEN c1 IS NULL THEN 0 END AS c1; I receive both time the error "Invalid column name 'c1'." The Syntax (source ) of INSERT INTO is: INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
Asked by sqlNewie (53 rep)
Apr 4, 2019, 10:31 AM
Last activity: Apr 5, 2019, 08:27 AM