Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2005, 04:10 PM
Registered User
 
Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tconlan25 Send a message via MSN to tconlan25 Send a message via Yahoo to tconlan25
Default Integers in SQL Server

Here is my dilemma:

I'm working on a project where I need to import data from Excel into SQL Server for storage. The way I have it working is DTS pulls the information into temp tables so I can scrub the data (remove null rows, etc). Then a stored procedure pulls the data from the temp table into a supertype table where primary keys are assigned in an IDENTITY column. The primary keys are then pulled into separate subtype tables. I'm using a cursor when I pull the data from the temp table into the supertype table so I can assign the lookup table foreign keys that describe each primary, and then do the same when I move the primary keys to the subtype tables. Unfortunately because of the way SQL Server sorts numbers, my primary keys are not in the order I require. Is there a way around this? If I can provide more clarity to my process here let me know and I'll see what I can do. Thanks in advance

********************
Tim Conlan
DBA Intern
LendingTree, LLC
 
Old August 18th, 2005, 01:36 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

please post some of your data and the desired result.

 
Old August 23rd, 2005, 09:43 AM
Registered User
 
Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tconlan25 Send a message via MSN to tconlan25 Send a message via Yahoo to tconlan25
Default

I decided to go a different route with this, instead of calling a cursor with the last record, I use the MAX() function which returns my largest value and assign it to a variable. Then I just decrease the value of the variable as I move through the data. Probably not the most efficient or glamorous method, but I'm getting what I want out of it.

Tim
Intern

********************
Tim Conlan
DBA Intern
LendingTree, LLC
 
Old August 23rd, 2005, 10:08 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Acually, that is the correct way t do it. Using a loop is better than a Cursor... Cursors are pretty much a no-no in SQL.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflict in SQL Server 2000 and SQL Server 2005 ayan.mukherjee SQL Language 0 June 30th, 2008 03:34 AM
SQL Server Reg. SQL Server does not exist error Arsi SQL Server 2000 1 June 11th, 2008 11:20 AM
migrating from sql server 2000 to sql server 2005 abinashpatra SQL Server 2005 2 December 1st, 2006 03:45 PM
Unsigned integers AndrewH Java Basics 1 September 26th, 2006 02:46 PM
Passing global integers to SQL statements Kenny Alligood Access VBA 4 August 14th, 2003 10:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.