April 19, 2010 at 4:56 am
Dear all,
i need to generate the locations id depends up on the state as well as
track number is auto incremented
Samples Data Example:
[STATE] , [LOCATION ID],[TRACK NO]
LOS ANGELS 10000011
LOS ANGELS 10000012
LOS ANGELS 10000013
LOS ANGELS 10000014
CALIFORNIA 10000021
CALIFORNIA 10000022
CALIFORNIA 10000023
CALIFORNIA 10000024
Here I need to generate the Location id and Track no
automatically based on State..
April 19, 2010 at 5:33 am
Buddy, request unclear.. can u pls post some visual representation of your desired result based on the location and track number??
April 19, 2010 at 5:44 am
Yes, Table name is Location_master
The columns are like :
STATE , LOCATION_ID , TRACK NUMBER, ETC..
HERE THE DATA's WILL INSERT INTO LOCATION_MASTER
BUT WE NEED TO GENERATE THE location_id and Track number auto
group by State,
WITH BELOW FORMAT ...
LOS ANGELS 1000001 1
LOS ANGELS 1000001 2
LOS ANGELS 1000001 3
LOS ANGELS 1000001 4
CALIFORNIA 1000002 1
CALIFORNIA 1000002 2
CALIFORNIA 1000002 3
CALIFORNIA 1000002 4
April 19, 2010 at 5:54 am
Without Table structure, or sample data we cant proceed further buddy :(.. and thats the reason tho u have 20 views, u have only 2 replies...
But for a starter, i will give u this..
SELECT
ROW_NUMBER() OVER(PARTITION BY [STATE] , [LOCATION ID] ORDER BY [STATE] , [LOCATION ID]) AS TRACK_NUMBER ,
[STATE] ,
[LOCATION ID]
FROM
LOCATION_LOCATOR
Tell us if this helped you!!
April 19, 2010 at 6:08 am
Thank you so much..
My problem is track number generations, now i got a solutions , thanks... Location id i generated by cursor...
April 19, 2010 at 6:11 am
Had u posted the necessary DDL, sample data and desired output, people would have replied and fixed your problem just at the wink of your eyes..:-)
Anyways, happy to have helped you and glad your issue is resolved...
Cheers!!
April 19, 2010 at 7:04 am
Location id i generated by cursor...
this should have been mentioned earlier.i was only working with "state" column
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
April 19, 2010 at 7:36 am
Bhuvnesh (4/19/2010)
Location id i generated by cursor...
this should have been mentioned earlier.i was only working with "state" column
Thats the problem when the requirement is unclear with no DDL or sample data or desired output.. hmmm..
April 19, 2010 at 1:32 pm
Saravanan_tvr (4/19/2010)
Thank you so much..My problem is track number generations, now i got a solutions , thanks... Location id i generated by cursor...
Heh... yep... a cursor is definitely the way to go here. That way, you'll have something to fix in the future. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply