Reputation: 1
I want to export a table in DB2 where in which I want to return few column vaues as NULL due to some restrictions. I am looking for better alternatives to prepare the select query for export.
I can achieve it with the below select query. But the query is very long considering the table has many columns.
SELECT
COL1
,COL2
,COL3
,COL4
,REPLACE(COL5,NULL) AS COL5
,REPLACE(COL6,NULL) AS COL6
,COL7
,COL8
,COL9
,COL10
,COL11
,REPLACE(COL12,NULL) AS COL12
,COL13
,COL14
,COL15
,COL16
,COL17
,COL18
,REPLACE(COL19,NULL) AS COL19
,COL20
FROM
TABLE1
Is there any better alternatives?
Upvotes: 0
Views: 84
Reputation: 331
Use the following way to set column null value
SELECT
COL1
,COL2
,COL3
,COL4
,NULL AS COL5,
,NULL AS COL6
FROM TABLE1
Upvotes: 2