Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2008-03-11 : 09:34:06
|
Hi, I need help please. I have a pipe delimited qry where i output one column but it get to big (over 600 char). So now i'm trying to break it up, but i get the following error: Union,equal number of expressions in target list This what it was:select 'Period|Item|Channel|Region|SalesVolume|SalesValue' as OutputVar Union All Select rtrim(Period) +'|'+rtrim(V_Main) +'|'+str(SalesVolume,9,4) +'|'+str(SalesValue,9,4)Trying to convert it to:select 'Period|Item|Channel|Region' as OutputVar Union All Select rtrim(Period) +'|'+rtrim(V_Main) ,str(SalesVolume,9,4) as SalesVolume ,str(SalesValue,9,4) as SalesValuePlease Assist! |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-11 : 09:35:51
|
select 'Period|Item|Channel|Region' as OutputVar Union All Select rtrim(Period)+'|'+rtrim(V_Main) E 12°55'05.25"N 56°04'39.16" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-11 : 09:37:09
|
select 'Period|Item|Channel|Region' as OutputVar, '' as SalesVolume, '' AS SalesValueUnion All Select rtrim(Period)+'|'+rtrim(V_Main),str(SalesVolume,9,4),str(SalesValue,9,4) E 12°55'05.25"N 56°04'39.16" |
 |
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2008-03-11 : 10:32:03
|
Awesome - Thank You very much. It works great. I stuggled with this - it looks so simple once one has the solution - Thank You select 'Period|Item|Channel|Region' as OutputVar,'' as SalesVolume,'' as SalesValueUnion All Select rtrim(Period)+'|'+rtrim(V_Main),str(SalesVolume,9,4) as SalesVolume,str(SalesValue,9,4) as SalesValue |
 |
|
|
|
|
|
|