sql server - How to show blank instead of column value for all duplicated columns of a SQL query? -


there similar question answer known number of columns , single selection column. problem here have no knowledge of columns (count, type) of specified sql query , want blank columns not single column.

for example lets have following query.

select * view1 

result :

column(1)       column(2)         column(..)         column(n) 1                               sales              1500 2               c                 sales              2500 3               c                 sales              2500 4                               development        2500 

expected result :

column(1)       column(2)         column(..)         column(n) 1                               sales              1500 2               c                                    2500 3                                                         4                               development             

pseudo sql query :

exec proc_blank_query_result 'select * view1' 

if you're in sql server 2012 or newer, can lag, this:

select   nullif(column1, lag(column1) on (order yourorderbyclause)) column1,   nullif(column2, lag(column2) on (order yourorderbyclause)) column2,   ...   view1 

to make dynamic, have parse lot of metadata query. using sp_describe_first_result_set might idea, or use select into temp. table , parse columns of it.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -