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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help with Order By

Author  Topic 

ams006
Yak Posting Veteran

55 Posts

Posted - 2016-01-07 : 06:47:28
Hi,

I'm creating a table and ordering the table by DATE_ field.
When I do this in our test environment all works fine, however, when I do this in our production environment the Order By clause is disregarded.

Any ideas why this would happen?

below is my script:


BEGIN

CREATE table 'new table name'
(
SESSION_ID varchar(250),
ACCOUNT varchar(250),
OPEN_BALANCE numeric(20,2),
CLOSE_BALANCE numeric(20,2),
CREDITS numeric(20,2),
DEBITS numeric(20,2),
LSAMOUNT numeric(20,2),
CHARCODE1 varchar (10),
CHARCODE2 varchar (10),
CHARCODE3 varchar (10),
CHARCODE4 varchar (10),
CHARDESC1 varchar (250),
CHARDESC2 varchar (250),
CHARDESC3 varchar (250),
CHARDESC4 varchar (250),
OPEN_BALANCE_ABS numeric(20,2),
CLOSE_BALANCE_ABS numeric(20,2),
TRANS_CURRENCY varchar(3),
TRANS_AMOUNT numeric(20,2),
AMOUNT numeric (20,2),
FUNDOP_GROUP varchar(250),
GLENTRY_GROUP_REF_NO varchar(30),
FXRATE numeric(20,7),
MOVEMENT numeric(20,2),
COUNT int,
DATE_ datetime,
GL_OUTPUT varchar (50),
CHART_NAME varchar(250),
CHART_ID varchar(100),
ACCOUNT_TYPE varchar(50),
ACCOUNT_NO varchar(50),
ACCOUNT_NAME varchar(100),
FUND_IQID varchar(250),
SHORT varchar(250),
TOTALING varchar(250),
STARTDATE datetime,
ENDDATE datetime,
CURRENCY varchar(3),
KNOWN_AS varchar(250),
FUND_NAME varchar(250),
PRINTDATEANDTIME datetime
)

END

INSERT into 'new table name'

SELECT
@SESSION_ID as 'SESSION_ID',
#TableGL1.*

From #TableGL1
order by #TableGL1.DATE_ asc


Many thanks
   

- Advertisement -