Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:49:52+00:00 2026-05-28T04:49:52+00:00

SQL Server 2008: Sorry for the possibly non-informative title but I’m not sure quite

  • 0

SQL Server 2008:

Sorry for the possibly non-informative title but I’m not sure quite how to descirbe this problem. I am sure there is a really neat (and probably obvious!) way of solving it but I just can’t think.

Anyway, given input…

ObjectID    Field1   Field2   Field3 (actually about 10-12 fields some varchar(max)
1           x        y        z
2           x        y        z
3           x        y        b
4           x        q        r

I want to attach to each row a key that indicates to which ‘grouping’ it belongs. i.e. kind of like if you did a “GROUP BY Field1, Field2, Field3”. Need to end up with information equivalent to this…. not saying it has to look like this, but the “GroupID” has to be a GUID not an integer.

GroupID   ObjectID   
[guid1]       1
[guid1]       2
[guid2]       3
[guid3]       4  

(Probably) needs to be a set operation (input may be many 1000s of rows), needs to be as fast as possible as it also will happen fairly often. I thought about hashing the column values – but there is at least one varchar(max) field… in any case I don’t know if/how to actually do that in SQL either! [Not allergic to cursors but worry about speed – and don’t have good tools to run comparative tests].

As I said, the soultion is probably really obvious once you know it, but I really can’t think, been bashing my brain for a good few hours over a coupla days now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:49:53+00:00Added an answer on May 28, 2026 at 4:49 am

    I think DENSE_RANK() is what you need here:

    select DENSE_RANK() over (order by Field1, Field2, Field3 ) GroupID,
     /* insert other appropriate fields, but NOT object ID,  ^- here */
           ObjectID
    from MyTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In sql server 2008, I have the following query: select c.title as categorytitle, s.title
SQL Server 2008 - I want to concatenate four columns into delimited values, but
I'm trying to insert into XML column (SQL SERVER 2008 R2), but the server's
Sorry about the title, not sure how to describe without example. I trying to
Sql server 2008 R2 I have two queries DECLARE @title NVARCHAR(500) = 'Finite AND
SQL Server 2008. I have this very large query which has a high cost
DB: Sql Server 2008. I have a really (fake) groovy query like this:- SELECT
Sorry for the R101 question. I have a SQL Server 2008 table with a
In sql server 2008, I am using a pattern like this: begin transaction begin
SQL Server 2008 has new geo data types. One thing I am wondering though

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.