Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ID to be maintained manually

Author  Topic 

mounikakala
Starting Member

14 Posts

Posted - 2008-08-08 : 17:04:52
Hi,

we have a table with 6 million Records and are planning to move that data for a new application. The new application would add additional columns to this table and also we need an ID column which we should be able to modify later to club with matching records so that all matching records should have the same ID for reporting purposes.

Thanks
Mouni

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-08 : 17:05:46
http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mounikakala
Starting Member

14 Posts

Posted - 2008-08-08 : 18:11:44
Hi,

The link does not solve my problem nor gives a solution to my situation.

Thanks
Mounikakala
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-08 : 20:09:10
That links means you have not provided enough information so we can answer. Explain clearly ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-09 : 01:48:30
Give some sample data and explain what you want
Go to Top of Page

mounikakala
Starting Member

14 Posts

Posted - 2008-08-09 : 09:43:22
OK look at the Table below

CID |ST |Dtls1
345678 |NJ |x
345678 |CA |x
345678 |NY |x
987654 |NJ |x
987654 |TX |x
987654 |TX |x

These are some of the Columns in the existing table which contain millions of records.

For the first time when we copy all the data we are Additionally creating few more columns for our application purpose and populating them on the logic based on the existing data in the table. Now my requirement is a Column of Datatype Bigint that is like an Identity column but the difference is that we must be able to update that column on a later date to a value so that we can identify the records pertaining to same customer.

CID |ST |Dtls1 |ID
345678 |NJ |x |1
345678 |CA |x |2
345678 |NY |x |3 To be Changed to 1
987654 |NJ |x |4
987654 |TX |x |5
987654 |TX |x |6 To be Changed to 4

Now the Table Above is similar to what I need with the ID column increment initially and for reporting and other purposes, we need to change ID 3 to Value 1 so that the Customers records from NJ with CID 345678 and considering other columns is grouped to a same ID .

Also the same with the record ID 6, the ID must be changed to 4.

The sample data is not being displayed in column row format in the post so I have included Pipe Delimited differentiating the columns data for each row


I hope this is very clear.

Thanks in Advance

Mounikakala
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-09 : 09:48:19
for the first time when you transfer the data over, you can use row_number() to create a sequential running no. Look up row_number() function in the Boos OnLine


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-09 : 11:40:20
What decides which of the rows need to be grouped together?
Go to Top of Page

mounikakala
Starting Member

14 Posts

Posted - 2008-08-09 : 12:35:50
Hi Visakh,

The Unique Combination of CID and the ST Columns needed to be grouped together.

If the logic to maintain the ID Column is given it would be helpful to me.

Thanks

Mounikakala
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-09 : 13:08:58
then how do you group records with ST values NJ & NY? didnt get that
Go to Top of Page

mounikakala
Starting Member

14 Posts

Posted - 2008-08-09 : 13:58:39
Hi Visakh

Sorry , it was Mistake that I typed NY instead of NJ.

The Value must have been NJ in the Row
345678 |NY |x |3 To be Changed to 1

the correct row will be
345678 |NJ |x |3 To be Changed to 1

I only need to group only records with ST NJ.

Mounikakala


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-09 : 14:23:53
then you can initially number the records by means of row_number() function as suggested by Khtan and later before grouping you can update them with min id value from each group.
Go to Top of Page
   

- Advertisement -