Hi everyone
I am working on a SSIS package that converts a table into CSV file. I need the CSV records to be sorted by date. I have 7 other tables and they are working as expected except for 1. I am not sure why the records are not sorted by date.
I was getting an arithmetic overflow error so I changed the size from 10 to 20. It fixed it. But I think it may have created the order issue. This is the only difference between the 7 other tables.
How do I get the records in AppStockTable to be sorted by date?
CREATE TABLE [dbo].[AppStockTable](
[SYMBOL] [nchar](10) NOT NULL,
[INTERVAL] [nchar](1) NOT NULL,
[DATE] [date] NOT NULL,
[NAME] [nchar](40) NOT NULL,
[OPEN] [nchar](20) NOT NULL,
[HIGH] [nchar](10) NOT NULL,
[LOW] [nchar](10) NOT NULL,
[CLOSE] [nchar](20) NOT NULL,
[VOLUME] [nchar](20) NOT NULL
) ON [PRIMARY]
GO
INSERT INTO DBO.AppStockTable
SELECT'SPX' AS SYMBOL,
'D' AS INTERVAL,
T1.QUOTE_DATE AS [DATE],
'S&P 500' AS [NAME],
CAST(ROUND(T1.calc_1 *100000,0) AS INT) AS [OPEN],
9999999 AS [HIGH],
0 AS [LOW],
CAST(ROUND(T1.calc_2 *100000,0) AS INT) AS [CLOSE],
CAST(ROUND(T1.calc_3 *100000,0) AS INT) AS VOLUME
FROMDBO.StockTable AS T1
ORDER BY 3
you need to have the order by on the Dataflow Source sql - not where you insert into the table as per above.
March 18, 2023 at 9:25 pm
it worked! thank you so much
March 20, 2023 at 3:50 pm
"... ORDER BY 3 ..."
I recommend against this. Name the field.
If a new field gets added as 3rd field, you will get different results.
And, nobody knows what field '3' is, so extra time wasted to find out.
March 20, 2023 at 3:53 pm
Is there a reason you don't have a clustered index or primary key? (may or may not be the same)
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy