Showing posts with label assigned. Show all posts
Showing posts with label assigned. Show all posts

Monday, March 26, 2012

Order by Issue

I am having a small issue with the order by command.

Everytime I run the code below, everything displays in the correct order which was assigned by the order by command:

select *
from [table1]
order by column_a, column_b, column_c

My problem is that I want it to be stored in another table in the order that I specify, so I run the code below which has the same order:

select *
into [new table]
from [table1]
order by column_a, column_b, column_c

My problem is that when I do a select * form the new table that I inserted all the information into in order, it will not be returned in order. Why would that be? My understanding is that it would store the info in the new table by the way I specified on the order by line.

Any help would be appreciated. It is driving me crazy!Data in a recordset has no order unless specified. While you may have specified an order when you inserted the records, there is no guarantee that they will be maintained in that order, or returned in that order.

You can ensure that they are stored in a specific order by placing a clustered index on the columns you want, and MOST of the time queries against the table will return the records in that order, but again there is no guarantee.

You should always issue an ORDER BY clause on all SQL Statements which require data to be returned in a specified order.|||The only time the resultset will be in the order of the clustered index is if you run your SELECT on a single processor machine, or if you set only 1 processor for SQL Server service, or if you use OPTION (MAXDOP 1). In any other case the order of the clustered index does not affect the order of the resultset without ORDER BY.

Monday, March 19, 2012

OracleDBA need help on SQLSERVER tool


Hi, I am an oracle DBA, now I am just assigned todo something over our SQLSERVER database. I don't know anything about SQLSERVER. So far, I have SQLSERVER Enterprise Manager Client on my machine. I can't find anywhere that has something like Oracle's SQLPlus where I can run scripts, it seems the EM tool can only run query against one table at a time by clicking that table...I may be wrong though. Can someone gives me some hints?

My main responsibility is to move those sqlserver data to oracle database, I find there is export utility in sqlserver EM that I can use to move data. But I also need to run some query to check if the migration is error free. so my questions are:

How I can create links to Oracle (or is it possible?) and is it possible to run the query against oracle from sqlserver? any document links?

Anyplace I can run the sql scripts instead of right click each table?

Can anyone point me to some documents for a sqlserver beginner?

Thanks in advance.

If you are running enterprise manager, I would assume you are on SQL 2000. If so, Select Tools, Query Analyzer.

This is a GUI for running any SQL.

HTH

|||
Hi, Bob:

I got the query tool, thanks a lot.

Any one can give me a hint as to how to create links within sqlserver to oracle database?

Thanks in advnace