| Author |
Topic |
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-10-04 : 04:09:27
|
| I have quite a long SP which is made up of various tables, temp tables, etc.I am creating 11 physical tables which i am using to create a DTS package to auto output to an excel spreadsheet (template for a report).The problem is although i have used ORDER BY statements to sort the data in ascending order the data isnt sorted.Heres an example of one of the table outputs--Create Table of ManagersDELETE FROM Weekly_Term_Code_Output7INSERT INTO Weekly_Term_Code_Output7SELECT #Temp_Agent.ManagerFROM #temp5 INNER JOIN #Temp_Agent ON #temp5.agent_login = #Temp_Agent.agent_loginWHERE (NOT (#Temp_Agent.Manager IS NULL))GROUP BY #Temp_Agent.ManagerORDER BY #Temp_Agent.Managerive also tried placing an order by statement in the output to excel in the DTS package but this also doesnt work?Any ideas anyone?? |
|
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-10-04 : 04:10:13
|
| Sorthing else ive noticed is all the text in excel has a leading ' in every cell |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-04 : 04:11:49
|
[code]-- Create Table of ManagersTRUNCATE TABLE Weekly_Term_Code_Output7INSERT Weekly_Term_Code_Output7SELECT DISTINCT ta.ManagerFROM #temp5 AS t5INNER JOIN #Temp_Agent AS ta ON ta.agent_login = t5.agent_loginWHERE ta.Manager IS NOT NULLORDER BY ta.Manager[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-10-04 : 04:23:45
|
| Many thanks for your help this worked. |
 |
|
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-10-04 : 06:03:11
|
| I cant seem to get this query to work i get a Invalid column name 'Summary'.Im not sure if this is because i am linking columns to create my summary?TRUNCATE TABLE Weekly_Term_Code_Output11INSERT Weekly_Term_Code_Output11SELECT DISTINCT #temp5.App_Name, #temp5.term_code, #temp5.display_text, #temp5.App_Name+' '+#temp5.term_code+' '+#temp5.display_text as Summary,#temp5.kvi, #temp5.min_re, #temp5.max_reFROM #temp5GROUP BY #temp5.App_Name, #temp5.term_code, #temp5.display_text, #temp5.Summary,#temp5.kvi, #temp5.min_re, #temp5.max_reORDER BY #temp5.App_Name, #temp5.term_codeGO |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-10-04 : 06:07:26
|
quote: Originally posted by jtwork I cant seem to get this query to work i get a Invalid column name 'Summary'.Im not sure if this is because i am linking columns to create my summary?TRUNCATE TABLE Weekly_Term_Code_Output11INSERT Weekly_Term_Code_Output11SELECT DISTINCT #temp5.App_Name, #temp5.term_code, #temp5.display_text, #temp5.App_Name+' '+#temp5.term_code+' '+#temp5.display_text as Summary,#temp5.kvi, #temp5.min_re, #temp5.max_reFROM #temp5GROUP BY #temp5.App_Name, #temp5.term_code, #temp5.display_text, #temp5.Summary,#temp5.kvi, #temp5.min_re, #temp5.max_reORDER BY #temp5.App_Name, #temp5.term_codeGO
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-04 : 06:38:56
|
Remember that is not allowed in SQL Server 2005.I just tought you how to use ALIASES. Why do you revert from that path?TRUNCATE TABLE Weekly_Term_Code_Output11INSERT Weekly_Term_Code_Output11SELECT DISTINCT App_Name, term_code, display_text, App_Name + ' ' + term_code + ' ' + display_text as Summary, kvi, min_re, max_reFROM #temp5ORDER BY App_Name, term_code E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-10-04 : 06:43:04
|
| Thank you. I have already written my code and will tidy up once i have the code working. |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2007-10-04 : 22:40:01
|
| This is potentially doomed to fail no matter what you do to your insert statement. The order is determined by the select, not by the insert. Any order by on an insert serves only to allocate an identity number in that order. You will need to put the order by in the DTS where you select from your final table. |
 |
|
|
|