1

Topic: Create a cross tab function SQL

create procedure spr_CrossTab   

    @SelectStatement varchar(8000),   
    @colsHorizontal varchar(100), 
    @content varchar(100),   
    @colsVertikal varchar(100), 
    @colsAdditional varchar(100) = Null 

AS 
 
set nocount on 
set ansi_warnings off 
 
declare @Values varchar(8000); 
set @Values = ''; 
 
set @colsAdditional= isNull(', ' + @colsAdditional,'') 
 
create table #Temp (Tempfield varchar(100)) 
 
insert into #Temp 
exec ('select distinct convert(varchar(100),' + @colsHorizontal + ') as Tempfield FROM (' + @SelectStatement + ') A') 
 
select @Values = @Values + ', ' +   
replace(replace(@isi,'(','(CASE WHEN ' + @colsHorizontal + '=''' +   
Tempfield + ''' THEN '),')[', ' END) as [' + Tempfield ) 
from #Temp   
order by Tempfield 
 
drop table #Temp 
 
 
exec ( 'select ' + @colsVertikal + @colsAdditional + @Values +   
' from (' + @SelectStatement + ') A GROUP BY ' + @colsVertikal) 
 
set nocount off 
set ansi_warnings on

2

Re: Create a cross tab function SQL

you can have adequate economic banking to cover the losses particularly if you discover by yourself starting up out wholesale kids dresses . summer cocktail dresses Often consider under consideration that an afternoon vendor isn't going to devote funds on shares, they trip using the shares. It system they purchase a particular stock although it s soaring and encourage them the second it s heading another path. All carried out in a very one working day.Working day consumers don t invest in shares and grasp them. white cocktail dress  You need to also not get psychological with any shares you've Revisiting The World Of Bracelets by Pankaj Mohan . You ought to take care of shares like commodities, acquire even though minimal and market whilst substantial.If conceivable, you ll enroll in a acquiring and providing company and be informed the ropes. Typically, in case you re new to working day acquiring and promoting, a

3

Re: Create a cross tab function SQL

I think that this information is the best.

4

Re: Create a cross tab function SQL

Thanks a lot for the formula