Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Select 1

Status
Not open for further replies.

bikerboy718

Programmer
Feb 11, 2005
195
US
I have data from 2 tables (tableA and tableB) that needs to be combined into one table (tableC). The data has to go into tableC in a specific order. TableA data and then TableB data. To do this i use

Insert TableC
Select *
From TableA

Insert TableC
Select *
From TableB

However when i do a Select all on TableC and also check the table contents in Enterprise manager, TableB's data is listed first and then TableA's data. Is there a way for me to have tableA's data entered in first in the tableC and stay first in the tableC.

Normally i would not have a problem but for some reason this does not seem to be working.

Can anyone provide some light as to why this may be happening. Any help will be greatly appreciated.

Michael
 
The data will be ordered by SQL, depending on things like clustered index (defaulted as the PK), if no clustered index, how it is ordered on the heap.
If you want to order the data, have an additional column in TABLEC (perhaps an identity), then when querying TableC, use order by this new column



"I'm living so far beyond my income that we may almost be said to be living apart
 
I forgot i added PK's to the table. That was the reason the sorting was off. I switched it around a bit and it is all set. Thanks for your help.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top