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

There is a similar question which answer this for a known number of columns and only a single selection column. But the problem here is that
I have no knowledge of columns (count, type) of a specified SQL query and also I want to blank for all columns not a single column.

For example lets say I have following query.

  • Error authenticating proxy while running agent job
  • Sql Server sum multiple transactions done by a single transactionID
  • Comments table with multiple types of parents
  • how I can do stored procedure custom complex type using class mapping
  • Orchard: How to force all the migration codes to run after I've deleted the App_Folder?
  • SQL Express vs SQL CE, latency/lag
  • Select * from View1
    

    Result :

    Column(1)       Column(2)         Column(..)         Column(N)
    1               A                 Sales              1500
    2               C                 Sales              2500
    3               C                 Sales              2500
    4               A                 Development        2500
    

    Expected result :

    Column(1)       Column(2)         Column(..)         Column(N)
    1               A                 Sales              1500
    2               C                                    2500
    3                                                        
    4               A                 Development            
    

    Pseudo SQL Query :

    EXEC proc_blank_query_result 'Select * from View1'
    

    One Solution collect form web for “How to show blank instead of column value for all duplicated columns of a SQL query?”

    If you’re in SQL Server 2012 or newer, you can do this with lag, something like this:

    select
      nullif(column1, lag(column1) over (order by yourorderbyclause)) as column1,
      nullif(column2, lag(column2) over (order by yourorderbyclause)) as column2,
      ...
    from
      View1
    

    To make it dynamic, well then you have to parse a lot of metadata from the query. Using sp_describe_first_result_set might be a good idea, or use select into a temp. table and parse the columns of it.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.