Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts

Sunday, March 25, 2012

Dimension Hierarchy members processed incorrectly


I have an interesting problem with Analysis Services that I was able to resolve (sort of), but I would appreciate some feedback to see if this is known behavior, a bug, or if I'm just setting up my dimension incorrectly.

Basically, the intermediate members of a hierarchy are showing up incorrectly in my date dimension. For example, when I browse the dimension, I'll end up with a tree that looks like this:

All CY
- CY 1998
- Qtr 1 CY 1998
- January 1998
- Jan 1, 1998
- Jan 2, 1998
- etc.
- .....
- .....
- CY 2005
- Qtr 1 CY 1998
- January 1998
- Jan 1, 2005
- Jan 2, 2005
- etc.

As you can see, the years are correct and the lowest element (date) is correct, but the names of the intermediate elements (quarter and month) are incorrect. These intermediate elements are the same for each calendar year (i.e. it's always 1998, which is the earliest year we have data for in the table).

I've included the table/hierarchy structure below for reference.


So the way that I (sort of) resolved the issue was by using the calculated name values as the keys for the attributes instead of using the integer-based keys that I was using. It seems that you can't/shouldn't have key values that repeat for different higher-level elements (i.e. the month_si value of "12" (December) is present in the table for rows from CY 1998, 1999, 2000, etc.). I'm guessing here, but it seems that when it went to build the hierarchy underneath, say, CY 2006, it found key values of "1","2","3", & "4" for [quarter_si] (correctly so). It then pulled the value from [Column15] for those key values, but instead of limiting itself to data underneath CY 2006, it looked at the whole table, and thus pulled the name values for those quarters from the first records in the table, which happened to be "Qtr 1 CY 1998","Qtr 2 CY 1998" and so on. But since "Qtr 1 CY 2006" is only present in CY 2006, using "Qtr 1 CY 2006" as the key and name value gave me the correct hierarchy.

Unfortunately, this resolution doesn't work because the keys won't order correctly (i.e. "June 2006" comes before "May 2006" under "Qtr 2 CY 2006") and this is a show-stopper.

What's odd is that I converted this dimension directly from SSAS 2000, and this was not a problem we encountered in 2000. Is this issue resulting from something new introduced in SSAS 2005? Is there a property flag that controls this behavior?

Or do I just not have a good understanding of how dimensions work? ;)

I would appreciate anyone's feedback or comments.

Thanks in advance,
Jamie C.


TABLE/DIMENSION/HIERARCHY INFO:


The underlying table used for the dimension is "dbo.dci_Date" - the structure of the table (including calculated columns within AS) is this:

[dbo].[dci_Date]
[date_id_si] [smallint] NOT NULL,
[year_si] [smallint] NOT NULL,
[quarter_si] [smallint] NOT NULL,
[month_si] [smallint] NOT NULL,
[date_sd] [smalldatetime] NULL,


The following "virtual" columns are also present as calculated columns - I've included the formulas for reference:

[Column4] [WChar] = left("date_sd",11)
[Column13] [WChar] = 'CY ' + convert(char,DatePart(year,"date_sd"))
[Column15] [WChar] = 'Qtr ' + convert(CHAR, DatePart(quarter,"date_sd")) + 'CY ' + convert(char,DatePart(year,"date_sd"))
[Column17] [WChar] = convert(CHAR, DateName(month,"date_sd")) + convert(char,DatePart(year,"date_sd"))


Here's an example of what a couple of rows from the table look like (including the values for the calculated columns) - I've included the min & max as well:

[date_id_si],[year_si],[quarter_si],[month_si],[date_sd],[Column4],[Column13],[Column15],[Column17]
-729,1998,1,1,1998-01-01 00:00:00Z,Jan 1 1998,CY 1998,Qtr 1 CY 1998,January 1998 ** MIN
2495,2006,4,10,2006-10-30 00:00:00Z,Oct 30 2006,CY 2006,Qtr 4 CY 2006,October 2006
2496,2006,4,10,2006-10-31 00:00:00Z,Oct 31 2006,CY 2006,Qtr 4 CY 2006,October 2006
2497,2006,4,11,2006-11-01 00:00:00Z,Nov 1 2006,CY 2006,Qtr 4 CY 2006,November 2006
4270,2011,3,9,2011-09-09 00:00:00Z,Sep 9 2011,CY 2011,Qtr 3 CY 2011,September 2011 ** MAX


The hierarchy for this dimension (Calendar Year) is built with the following attributes:

Year -- key: [year_si] name: [Column13]
Quarter -- key: [quarter_si] name: [Column15]
Month -- key: [month_si] name: [Column17]
Day -- key: [Column4] name: [Column4]


Hello. You must assure that each attribute in a dimensions has an unique key. Like month, if you represent this with a month number like 1 to 12, this is not unique over years. To solve this problem you simply go to the key property of the attribute and change that to a collection by adding each year to column. By clicking to button to the right for the key column you will see the "Data Item Collection editor".

I would recommed to use numbers or collections of numbers as keys for year, quarters and months. Change the name column to something for informative instead, like a text based description. Check that the attribute is ordered by key, not by name in the properties for each attribute.

HTH

Thomas Ivarsson

|||

Thanks Thomas! I had a feeling that was the case, but it never hurts to be sure.

Best,

Jamie C.

Dimension Editor - Order By property

Hello
I have the "Order By" property set to "Name". By default this is in
ascending order. But I need to sort in descending order. How can I change
this?
Thanks
Imrahn
You can't set the order to descending directly, but you can create a Member
Property with a formula that orders in the reverse order.
For example :
100 - ASCII(<column>)
Jacco Schalkwijk
SQL Server MVP
"Imrahn Gamildien" <IGamildien@.PICSolutions.com> wrote in message
news:%23u$1pdbXEHA.2544@.TK2MSFTNGP10.phx.gbl...
> Hello
> I have the "Order By" property set to "Name". By default this is in
> ascending order. But I need to sort in descending order. How can I
change
> this?
> Thanks
> Imrahn
>
|||You can't set the order to descending directly, but you can create a Member
Property with a formula that orders in the reverse order.
For example :
100 - ASCII(<column>)
Jacco Schalkwijk
SQL Server MVP
"Imrahn Gamildien" <IGamildien@.PICSolutions.com> wrote in message
news:%23u$1pdbXEHA.2544@.TK2MSFTNGP10.phx.gbl...
> Hello
> I have the "Order By" property set to "Name". By default this is in
> ascending order. But I need to sort in descending order. How can I
change
> this?
> Thanks
> Imrahn
>

Dimension Editor - Order By property

Hello
I have the "Order By" property set to "Name". By default this is in
ascending order. But I need to sort in descending order. How can I change
this?
Thanks
ImrahnYou can't set the order to descending directly, but you can create a Member
Property with a formula that orders in the reverse order.
For example :
100 - ASCII(<column> )
Jacco Schalkwijk
SQL Server MVP
"Imrahn Gamildien" <IGamildien@.PICSolutions.com> wrote in message
news:%23u$1pdbXEHA.2544@.TK2MSFTNGP10.phx.gbl...
> Hello
> I have the "Order By" property set to "Name". By default this is in
> ascending order. But I need to sort in descending order. How can I
change
> this?
> Thanks
> Imrahn
>

Wednesday, March 7, 2012

Different target links for link in the same report

I spent quite a bit of time trying work around this problem. Can
anypne help me with this?
I have several reports that I want to sort on the Column. When I sort
on the Column I call the same report and pass the parameters back to
and just change the Order by clause to the Column name. In the case
when I call the report I want it to appear in the same window. So I
use Target=_top.
On another field on the report I want the report to open in a new
window. Even if I set the URL to RC:Target=_blank it still opens in
the Parent window. If I user Target=_blank when calling the main
report, then all links open in new windows including when I sort on a
column.
Thanks
TomIn the current version of reporting services, all link targets for drill
through hyperlinks must have the same target value. It can only be set on
the parent report using rc:LinkTarget.
--
Bryan Keller
Developer Documentation
SQL Server Reporting Services
A friendly reminder that this posting is provided "AS IS" with no
warranties, and confers no rights.
"tmcgrath" <tmcgrath@.vhb.com> wrote in message
news:9e370943.0408161035.3d7471cc@.posting.google.com...
> I spent quite a bit of time trying work around this problem. Can
> anypne help me with this?
> I have several reports that I want to sort on the Column. When I sort
> on the Column I call the same report and pass the parameters back to
> and just change the Order by clause to the Column name. In the case
> when I call the report I want it to appear in the same window. So I
> use Target=_top.
> On another field on the report I want the report to open in a new
> window. Even if I set the URL to RC:Target=_blank it still opens in
> the Parent window. If I user Target=_blank when calling the main
> report, then all links open in new windows including when I sort on a
> column.
> Thanks
> Tom|||I've tried adding javascript into the Jump to URL field but whenever I click
the links nothing happens... nothing at all. My Java is on at least on my
local machine... i don't know about the actual report server, otherwise
certain parts of the web site I'm working on wouldn't work at all. Would it
be the settings on the report server or just something I seem to have missed
here?
"Nikola Tepper" wrote:
> Look at my post from 8/26:
> I think I have a solution. If you want a particular link to be opened in a
> new window, enter this into the "Jump to URL" field:
> javascript:if(window.open(yourPage.aspx','RsWindow','width=400,height=500,location=0,menubar=0,status=0,toolbar=0,scrollbars=1',true)){}
> Just play with the javascript, and you can direct the link into any frame
> you like, although you have to keep in mind security measures for iframes and
> frames
>
> "Bryan Keller [MSFT]" wrote:
> > In the current version of reporting services, all link targets for drill
> > through hyperlinks must have the same target value. It can only be set on
> > the parent report using rc:LinkTarget.
> >
> > --
> > Bryan Keller
> > Developer Documentation
> > SQL Server Reporting Services
> >
> > A friendly reminder that this posting is provided "AS IS" with no
> > warranties, and confers no rights.
> >
> >
> > "tmcgrath" <tmcgrath@.vhb.com> wrote in message
> > news:9e370943.0408161035.3d7471cc@.posting.google.com...
> > > I spent quite a bit of time trying work around this problem. Can
> > > anypne help me with this?
> > > I have several reports that I want to sort on the Column. When I sort
> > > on the Column I call the same report and pass the parameters back to
> > > and just change the Order by clause to the Column name. In the case
> > > when I call the report I want it to appear in the same window. So I
> > > use Target=_top.
> > > On another field on the report I want the report to open in a new
> > > window. Even if I set the URL to RC:Target=_blank it still opens in
> > > the Parent window. If I user Target=_blank when calling the main
> > > report, then all links open in new windows including when I sort on a
> > > column.
> > >
> > > Thanks
> > > Tom
> >
> >
> >

Different sort orders

I have a report in which I sort out the top x customers withs best revenue.
Here I have sort on total revenue field.
But when i toggle the customer I need to get the data sorted by period
instead of revenue so that they can see how the different periods went.
Is it possible to have another sort order for the details than for the group
view ?
JackIn you table properties, you can sort the table using the sort tab, then also
use the group tab, edit the group you want to sort and set the sort on the
sort tab within the group.
--
U. Tokklas
"Jack Nielsen" wrote:
> I have a report in which I sort out the top x customers withs best revenue.
> Here I have sort on total revenue field.
> But when i toggle the customer I need to get the data sorted by period
> instead of revenue so that they can see how the different periods went.
> Is it possible to have another sort order for the details than for the group
> view ?
> Jack
>
>

different sort order id

When I am trying to restore a database, getting an error
message which says "database attempting to restore was
backed up under different sort order id than the one
currently running and atleast one of them is a non-binary
sort order. Operation terminating abnormally."
How I can I rectify this problem ?
I'm guessing this is happening under SQL 7.0. On SQL 7.0 you can only
restore backups that contain the same sort order as the server in which you
are trying to restore to. Basically SQL 7.0 supports only a single sort
order for the server. But SQL 2000 does not have this limitation. In SQL
2000 you have server, database even column level sort orders, so you should
be able to restore your database backup to a 2000 server.
You might consider using DTS to move the data from the source server to your
new target server that has a different sort order then your source server.
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Jagdish" <jnasit_x@.hss.hns.com> wrote in message
news:692701c42ea5$8b364e10$a101280a@.phx.gbl...
> When I am trying to restore a database, getting an error
> message which says "database attempting to restore was
> backed up under different sort order id than the one
> currently running and atleast one of them is a non-binary
> sort order. Operation terminating abnormally."
> How I can I rectify this problem ?
>

different sort order id

When I am trying to restore a database, getting an error
message which says "database attempting to restore was
backed up under different sort order id than the one
currently running and atleast one of them is a non-binary
sort order. Operation terminating abnormally."
How I can I rectify this problem ?I'm guessing this is happening under SQL 7.0. On SQL 7.0 you can only
restore backups that contain the same sort order as the server in which you
are trying to restore to. Basically SQL 7.0 supports only a single sort
order for the server. But SQL 2000 does not have this limitation. In SQL
2000 you have server, database even column level sort orders, so you should
be able to restore your database backup to a 2000 server.
You might consider using DTS to move the data from the source server to your
new target server that has a different sort order then your source server.
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Jagdish" <jnasit_x@.hss.hns.com> wrote in message
news:692701c42ea5$8b364e10$a101280a@.phx.gbl...
> When I am trying to restore a database, getting an error
> message which says "database attempting to restore was
> backed up under different sort order id than the one
> currently running and atleast one of them is a non-binary
> sort order. Operation terminating abnormally."
> How I can I rectify this problem ?
>

different sort order id

When I am trying to restore a database, getting an error
message which says "database attempting to restore was
backed up under different sort order id than the one
currently running and atleast one of them is a non-binary
sort order. Operation terminating abnormally."
How I can I rectify this problem ?I'm guessing this is happening under SQL 7.0. On SQL 7.0 you can only
restore backups that contain the same sort order as the server in which you
are trying to restore to. Basically SQL 7.0 supports only a single sort
order for the server. But SQL 2000 does not have this limitation. In SQL
2000 you have server, database even column level sort orders, so you should
be able to restore your database backup to a 2000 server.
You might consider using DTS to move the data from the source server to your
new target server that has a different sort order then your source server.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Jagdish" <jnasit_x@.hss.hns.com> wrote in message
news:692701c42ea5$8b364e10$a101280a@.phx.gbl...
> When I am trying to restore a database, getting an error
> message which says "database attempting to restore was
> backed up under different sort order id than the one
> currently running and atleast one of them is a non-binary
> sort order. Operation terminating abnormally."
> How I can I rectify this problem ?
>

Different sort order - same set up

I have copied and restore a database from one SQL 2000
server to another with the same set up. I then ran stored
procedures to insert data from one table to the resultant
table, and expect the data to be the same as that of the
original machine. I have discovered, however, that the
same data has been inserted, but the data sort order is
different of that of the original server. On the SQL
statement to insert data there is a group by and order by
clause so the inserted data should have the same order.
The resultant table does not have any indexes (on both
servers). Could anyone tell me what could have cause this?
This could be important to us, as the data in the
resultant table will be BCP out to a report server, and
the sort order could be crucial. I know I could possibly
solve the problem by adding clustered indexes, but I would
like to know the cause.
The only difference in specification is that the new
server is on Service Pack version 8:00:818 (SP3), and the
original server is on 8:00:760 (SP3).
Both servers have the same collation , and both on Windows
2000 SP3Only way to guarantee a certain order is to have ORDER BY in the queries. Not even having a
clustered index will guarantee getting the data in a certain order.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Alex" <alex.au@.ace-ina.com> wrote in message news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
> I have copied and restore a database from one SQL 2000
> server to another with the same set up. I then ran stored
> procedures to insert data from one table to the resultant
> table, and expect the data to be the same as that of the
> original machine. I have discovered, however, that the
> same data has been inserted, but the data sort order is
> different of that of the original server. On the SQL
> statement to insert data there is a group by and order by
> clause so the inserted data should have the same order.
> The resultant table does not have any indexes (on both
> servers). Could anyone tell me what could have cause this?
> This could be important to us, as the data in the
> resultant table will be BCP out to a report server, and
> the sort order could be crucial. I know I could possibly
> solve the problem by adding clustered indexes, but I would
> like to know the cause.
> The only difference in specification is that the new
> server is on Service Pack version 8:00:818 (SP3), and the
> original server is on 8:00:760 (SP3).
> Both servers have the same collation , and both on Windows
> 2000 SP3|||Thanks for the reply Tibor. The problem is , as I stated
earlier, the sql statement has got group by and order by
included, and insert into a table with no indexes. I am
trying to say that for some reason - same sql used to do
insert on two machines with same set up somehow result
with data stored in different order.
>--Original Message--
>Only way to guarantee a certain order is to have ORDER BY
in the queries. Not even having a
>clustered index will guarantee getting the data in a
certain order.
>--
>Tibor Karaszi, SQL Server MVP
>Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
>"Alex" <alex.au@.ace-ina.com> wrote in message
news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
>> I have copied and restore a database from one SQL 2000
>> server to another with the same set up. I then ran
stored
>> procedures to insert data from one table to the
resultant
>> table, and expect the data to be the same as that of the
>> original machine. I have discovered, however, that the
>> same data has been inserted, but the data sort order is
>> different of that of the original server. On the SQL
>> statement to insert data there is a group by and order
by
>> clause so the inserted data should have the same order.
>> The resultant table does not have any indexes (on both
>> servers). Could anyone tell me what could have cause
this?
>> This could be important to us, as the data in the
>> resultant table will be BCP out to a report server, and
>> the sort order could be crucial. I know I could possibly
>> solve the problem by adding clustered indexes, but I
would
>> like to know the cause.
>> The only difference in specification is that the new
>> server is on Service Pack version 8:00:818 (SP3), and
the
>> original server is on 8:00:760 (SP3).
>> Both servers have the same collation , and both on
Windows
>> 2000 SP3
>
>.
>|||Sorry, I missed the part that the statements has ORDER BY. Does the columns you ORDER BY over have
the same collation? Try with sp_help <tblname>.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Alex" <anonymous@.discussions.microsoft.com> wrote in message
news:2b58301c3930c$3af2b0e0$a601280a@.phx.gbl...
> Thanks for the reply Tibor. The problem is , as I stated
> earlier, the sql statement has got group by and order by
> included, and insert into a table with no indexes. I am
> trying to say that for some reason - same sql used to do
> insert on two machines with same set up somehow result
> with data stored in different order.
> >--Original Message--
> >Only way to guarantee a certain order is to have ORDER BY
> in the queries. Not even having a
> >clustered index will guarantee getting the data in a
> certain order.
> >
> >--
> >Tibor Karaszi, SQL Server MVP
> >Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> >"Alex" <alex.au@.ace-ina.com> wrote in message
> news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
> >> I have copied and restore a database from one SQL 2000
> >> server to another with the same set up. I then ran
> stored
> >> procedures to insert data from one table to the
> resultant
> >> table, and expect the data to be the same as that of the
> >> original machine. I have discovered, however, that the
> >> same data has been inserted, but the data sort order is
> >> different of that of the original server. On the SQL
> >> statement to insert data there is a group by and order
> by
> >> clause so the inserted data should have the same order.
> >> The resultant table does not have any indexes (on both
> >> servers). Could anyone tell me what could have cause
> this?
> >> This could be important to us, as the data in the
> >> resultant table will be BCP out to a report server, and
> >> the sort order could be crucial. I know I could possibly
> >> solve the problem by adding clustered indexes, but I
> would
> >> like to know the cause.
> >>
> >> The only difference in specification is that the new
> >> server is on Service Pack version 8:00:818 (SP3), and
> the
> >> original server is on 8:00:760 (SP3).
> >>
> >> Both servers have the same collation , and both on
> Windows
> >> 2000 SP3
> >
> >
> >.
> >|||And what Tibor is trying to say is that unless you specify ORDER BY then you
cannot guarantee the order you get the data back.
--
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Alex" <anonymous@.discussions.microsoft.com> wrote in message
news:2b58301c3930c$3af2b0e0$a601280a@.phx.gbl...
> Thanks for the reply Tibor. The problem is , as I stated
> earlier, the sql statement has got group by and order by
> included, and insert into a table with no indexes. I am
> trying to say that for some reason - same sql used to do
> insert on two machines with same set up somehow result
> with data stored in different order.
> >--Original Message--
> >Only way to guarantee a certain order is to have ORDER BY
> in the queries. Not even having a
> >clustered index will guarantee getting the data in a
> certain order.
> >
> >--
> >Tibor Karaszi, SQL Server MVP
> >Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> >"Alex" <alex.au@.ace-ina.com> wrote in message
> news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
> >> I have copied and restore a database from one SQL 2000
> >> server to another with the same set up. I then ran
> stored
> >> procedures to insert data from one table to the
> resultant
> >> table, and expect the data to be the same as that of the
> >> original machine. I have discovered, however, that the
> >> same data has been inserted, but the data sort order is
> >> different of that of the original server. On the SQL
> >> statement to insert data there is a group by and order
> by
> >> clause so the inserted data should have the same order.
> >> The resultant table does not have any indexes (on both
> >> servers). Could anyone tell me what could have cause
> this?
> >> This could be important to us, as the data in the
> >> resultant table will be BCP out to a report server, and
> >> the sort order could be crucial. I know I could possibly
> >> solve the problem by adding clustered indexes, but I
> would
> >> like to know the cause.
> >>
> >> The only difference in specification is that the new
> >> server is on Service Pack version 8:00:818 (SP3), and
> the
> >> original server is on 8:00:760 (SP3).
> >>
> >> Both servers have the same collation , and both on
> Windows
> >> 2000 SP3
> >
> >
> >.
> >|||Tibor
The two server are of the same collation
(SQL_Latin1_General_CP1_CI_AS) and nothing was specified
on the columns during insert.
What happened was that we are migrating a database from
one server to another server. Using the same codes but the
result from the second server was of different sort order.
Software wise are the same I can only think of something
in the set up. The original database is in US, and we are
migrating it to UK. Also the UK Server SP3 version
8:00:818 is the only difference to US ( 8:00:760)
>--Original Message--
>Sorry, I missed the part that the statements has ORDER
BY. Does the columns you ORDER BY over have
>the same collation? Try with sp_help <tblname>.
>--
>Tibor Karaszi, SQL Server MVP
>Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
>"Alex" <anonymous@.discussions.microsoft.com> wrote in
message
>news:2b58301c3930c$3af2b0e0$a601280a@.phx.gbl...
>> Thanks for the reply Tibor. The problem is , as I stated
>> earlier, the sql statement has got group by and order by
>> included, and insert into a table with no indexes. I am
>> trying to say that for some reason - same sql used to do
>> insert on two machines with same set up somehow result
>> with data stored in different order.
>> >--Original Message--
>> >Only way to guarantee a certain order is to have ORDER
BY
>> in the queries. Not even having a
>> >clustered index will guarantee getting the data in a
>> certain order.
>> >
>> >--
>> >Tibor Karaszi, SQL Server MVP
>> >Archive at: http://groups.google.com/groups?oi=djq&as
>> ugroup=microsoft.public.sqlserver
>> >
>> >
>> >"Alex" <alex.au@.ace-ina.com> wrote in message
>> news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
>> >> I have copied and restore a database from one SQL
2000
>> >> server to another with the same set up. I then ran
>> stored
>> >> procedures to insert data from one table to the
>> resultant
>> >> table, and expect the data to be the same as that of
the
>> >> original machine. I have discovered, however, that
the
>> >> same data has been inserted, but the data sort order
is
>> >> different of that of the original server. On the SQL
>> >> statement to insert data there is a group by and
order
>> by
>> >> clause so the inserted data should have the same
order.
>> >> The resultant table does not have any indexes (on
both
>> >> servers). Could anyone tell me what could have cause
>> this?
>> >> This could be important to us, as the data in the
>> >> resultant table will be BCP out to a report server,
and
>> >> the sort order could be crucial. I know I could
possibly
>> >> solve the problem by adding clustered indexes, but I
>> would
>> >> like to know the cause.
>> >>
>> >> The only difference in specification is that the new
>> >> server is on Service Pack version 8:00:818 (SP3), and
>> the
>> >> original server is on 8:00:760 (SP3).
>> >>
>> >> Both servers have the same collation , and both on
>> Windows
>> >> 2000 SP3
>> >
>> >
>> >.
>> >
>
>.
>|||The two burning questions are:
1. The collation on the *column*, not the server. Check using sp_help <tblname>.
2. The query. That you indeed have an ORDER BY in the query.
If above both hold (same collation in all column(s) in all tables on both servers; and you do have
ORDER BY on the query and run exactly the same query on both servers), then it is strange.
Unless you have a collation where SQL Server "doesn't care". Some old SQL collation didn't care if
the upper or lower case letter was returned first. Say you have 'alex' and 'Alex' - which one should
come first? Does it matter?
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Alex" <anonymous@.discussions.microsoft.com> wrote in message
news:066601c39312$04bf5bd0$a001280a@.phx.gbl...
> Tibor
> The two server are of the same collation
> (SQL_Latin1_General_CP1_CI_AS) and nothing was specified
> on the columns during insert.
> What happened was that we are migrating a database from
> one server to another server. Using the same codes but the
> result from the second server was of different sort order.
> Software wise are the same I can only think of something
> in the set up. The original database is in US, and we are
> migrating it to UK. Also the UK Server SP3 version
> 8:00:818 is the only difference to US ( 8:00:760)
> >--Original Message--
> >Sorry, I missed the part that the statements has ORDER
> BY. Does the columns you ORDER BY over have
> >the same collation? Try with sp_help <tblname>.
> >
> >--
> >Tibor Karaszi, SQL Server MVP
> >Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> >"Alex" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:2b58301c3930c$3af2b0e0$a601280a@.phx.gbl...
> >> Thanks for the reply Tibor. The problem is , as I stated
> >> earlier, the sql statement has got group by and order by
> >> included, and insert into a table with no indexes. I am
> >> trying to say that for some reason - same sql used to do
> >> insert on two machines with same set up somehow result
> >> with data stored in different order.
> >>
> >> >--Original Message--
> >> >Only way to guarantee a certain order is to have ORDER
> BY
> >> in the queries. Not even having a
> >> >clustered index will guarantee getting the data in a
> >> certain order.
> >> >
> >> >--
> >> >Tibor Karaszi, SQL Server MVP
> >> >Archive at: http://groups.google.com/groups?oi=djq&as
> >> ugroup=microsoft.public.sqlserver
> >> >
> >> >
> >> >"Alex" <alex.au@.ace-ina.com> wrote in message
> >> news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
> >> >> I have copied and restore a database from one SQL
> 2000
> >> >> server to another with the same set up. I then ran
> >> stored
> >> >> procedures to insert data from one table to the
> >> resultant
> >> >> table, and expect the data to be the same as that of
> the
> >> >> original machine. I have discovered, however, that
> the
> >> >> same data has been inserted, but the data sort order
> is
> >> >> different of that of the original server. On the SQL
> >> >> statement to insert data there is a group by and
> order
> >> by
> >> >> clause so the inserted data should have the same
> order.
> >> >> The resultant table does not have any indexes (on
> both
> >> >> servers). Could anyone tell me what could have cause
> >> this?
> >> >> This could be important to us, as the data in the
> >> >> resultant table will be BCP out to a report server,
> and
> >> >> the sort order could be crucial. I know I could
> possibly
> >> >> solve the problem by adding clustered indexes, but I
> >> would
> >> >> like to know the cause.
> >> >>
> >> >> The only difference in specification is that the new
> >> >> server is on Service Pack version 8:00:818 (SP3), and
> >> the
> >> >> original server is on 8:00:760 (SP3).
> >> >>
> >> >> Both servers have the same collation , and both on
> >> Windows
> >> >> 2000 SP3
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >|||> On the SQL
> statement to insert data there is a group by and order by
> clause so the inserted data should have the same order.
I understand you basically have something like:
INSERT INTO MyTable
SELECT MyColumn
FROM MyOtherTable
GROUP BY MyColumn
ORDER BY MyColumn
And rows are not returned in sequence by the ordered column when you
run:
SELECT MyColumn
FROM MyTable
This is because the insert query is writing data to a table, not a
sequential file. Because a table is an unordered set of rows, a
relational database may return data in no particular sequence unless
constrained by an ORDER BY clause. As stated by the other responses,
you *must* specify ORDER BY on this SELECT query in order to guarantee
ordering:
SELECT MyColumn
FROM MyTable
ORDER BY MyTable
--
Hope this helps.
Dan Guzman
SQL Server MVP
--
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--
"Alex" <alex.au@.ace-ina.com> wrote in message
news:2b3b001c392fb$3e127730$a601280a@.phx.gbl...
> I have copied and restore a database from one SQL 2000
> server to another with the same set up. I then ran stored
> procedures to insert data from one table to the resultant
> table, and expect the data to be the same as that of the
> original machine. I have discovered, however, that the
> same data has been inserted, but the data sort order is
> different of that of the original server. On the SQL
> statement to insert data there is a group by and order by
> clause so the inserted data should have the same order.
> The resultant table does not have any indexes (on both
> servers). Could anyone tell me what could have cause this?
> This could be important to us, as the data in the
> resultant table will be BCP out to a report server, and
> the sort order could be crucial. I know I could possibly
> solve the problem by adding clustered indexes, but I would
> like to know the cause.
> The only difference in specification is that the new
> server is on Service Pack version 8:00:818 (SP3), and the
> original server is on 8:00:760 (SP3).
> Both servers have the same collation , and both on Windows
> 2000 SP3

Sunday, February 19, 2012

Different Database

I have two databases one is active the other is HIstory data. I need a command button or link or some sort of interface to the other database. Can that be done with a trigger or stored procedure?? How would I go about doing that in (has an access interface, sql engine)You would do it the same way you build an interface to the production system. I guess I'm confused about what you are asking.