Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 21st, 2004, 10:41 PM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
Question Fields/rows in SQL Server

Hey everyone. I have a really weird problem that I haven't been able to understand. After I upsize my DB in Access to SQL Server, I notice rows in one particular table are rearranged. The first column in this table is the ID and was autonumber in Access. It begins from 1 and goes all the way to 2000. But after upsizing, some rows in this column are rearranged. They're still there but not in order anymore. The weird thing is this very first time I upsized, this never happened. Over time though the data just rearranged for some reason. Anyone know why this happens? I thought I could use the sort button up top to sort a certain column but it's always disabled and I can't use it.
__________________
Keep it Prodigy, Keep it Real

Reply With Quote
  #2  
Old October 22nd, 2004, 02:42 AM
Leslie's Avatar
Leslie Leslie is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Honolulu
Posts: 184 Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 20 h 29 m 2 sec
Reputation Power: 9
Regarding sorting the table, when you open the table (return all rows) on the SQL Server there is a little button that says SQL. when you click on this you get a window above the results with:

"SELECT *
FROM (tablename)"

You can now add

"ORDER BY (column name)" and click the red ! button.

That will sort your resuts while you have the table open. If you need your results permanantly sorted, create a view on that table and sort the view.


And by the way, SQL Server's "autonum" is a numeric datatype such as int, with property "identity" set to "yes" in table design, and set your seed value as well as your increment value. If your table does not have this, the autonum property of your table did not convert from MS Access which might explain why your data is suddenly out of whack.

Reply With Quote
  #3  
Old October 22nd, 2004, 02:31 PM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
Leslie, you're right about the identity option. Mine is set to no. So how do I upsize my Access DB with autonumber on? Or can I just open the table in design view in SQL server and change the identity to yes?

Reply With Quote
  #4  
Old October 24th, 2004, 06:06 PM
Leslie's Avatar
Leslie Leslie is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Honolulu
Posts: 184 Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level)Leslie User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 20 h 29 m 2 sec
Reputation Power: 9
I believe you can sort your table on your autonum column and look at the last used number, change the identity to yes and force the seed number to start with the next unused number. Give it a try and let me know. If autonum converted as non-numeric SQL Server will not let you change the data type to number though.

If that doesn't work there are lots of data manipulation techniques you can use ... for instance, you can rename your table as TABLENAME2 and create the table structure for TABLENAME without any data. Set your identity column, then INSERT INTO TABLENAME by selecting from TABLENAME2 but be sure you ORDER BY AUTONUM in the select portion of the statement so the records insert in order. Otherwise it will automatically reassign the primary key as it inserts the random data. Hope that helps!

Reply With Quote
  #5  
Old October 24th, 2004, 07:10 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Your keys should be preserved if you use the upsizing wizard.

If you are using another method to upsize, you can SET IDENTITY INSERT ON to allow inserts into an identity column.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #6  
Old October 24th, 2004, 10:07 PM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
Doug, how do you preserve your keys when upsizing?

Reply With Quote
  #7  
Old October 24th, 2004, 11:09 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
How are you upsizing? iirc there is a choice in the Access upsize wizard.

Reply With Quote
  #8  
Old October 25th, 2004, 12:29 AM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
Well I choose validation rules, defaults, table relationships, plus use DRI and No timestamp fields or tables. I'm starting to think that I should upsize with the indexes?? I only didn't because I remember reading somewhere that it wasn't good or necessary to include them.

Reply With Quote
  #9  
Old October 25th, 2004, 06:31 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
I haven't upsized a DB for a couple years, unfortunately I don't recall all the details. Maybe DTS would work better, if you have access to DTS (Data Transfer) which is normally installed with SQL Server. I'd suggest an empty database on the SQL Server to experiment and test your upsizing, then just see what happens with different settings.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Fields/rows in SQL Server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT