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 3671808
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:31:56+00:00 2026-05-19T02:31:56+00:00

I have a table in SQL Server 2005 which contains some changelog data for

  • 0

I have a table in SQL Server 2005 which contains some changelog data for a number of projects. These are stored in one table as there are hundreds of projects and the projectlog table can be queried for things like activity per day or per person.

Eg
projectlogidentity int identity
projectname nvarchar(100)
projectchanged datetime
projectchangedby nvarchar(100)
projectserial int

There are indexes on projectname and projectserial

I want to generate a sequential projectserial per project as rows are added

eg:

0 | coffee shop | 7 Jan 2011 08:13 | derek | 0
1 | disco | 7 Jan 2011 08:18 | emma| 0
2 | coffee shop | 7 Jan 2011 08:19 | peter| 1
3 | disco | 7 Jan 2011 09:11 | alan| 1
4 | coffee shop | 7 Jan 2011 09:42 | tess | 2

So when retrieving the rows for a single project by projectname there is a persistent sequential serial number for each row specific to that projectname.

After inserting the row I currently do:

update projectlog set projectserial=1+
(select isnull(max(projectserial),0) from projectlog 
where projectname='coffee shop') where (projectlogidentity=4);

but I’m worried about performance when this table will contain hundreds of thousands of rows and hundreds of projects. Is there a better way?

thanks

Derek

  • 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-19T02:31:57+00:00Added an answer on May 19, 2026 at 2:31 am

    i think you can use two table for performance.

    projectlog 
    ----------
    projectlogidentity int identity
    projectnameid int
    projectchanged datetime
    projectchangedby nvarchar(100)
    projectserial int
    
    
    projectlog_projectname
    ----------------------
    id int
    name nvarchar(100)
    serial int
    
    UPDATE projectlog SET projectserial = 1 + (SELECT ISNULL(serial, 0) FROM projectlog_projectname WHERE projectname='coffee shop')
    WHERE projectlogidentity = 4;
    UPDATE projectlog_projectname SET serial += 1 WHERE projectname='coffee shop'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server 2005 table that has a varchar(250) field which contains
I have a sql server 2005 database which contains a user table.. Is it
I have a table in SQL Server 2005 SP4; in which one of the
I have a table in my sql server 2005 database which contains about 50
I have a table in SQL Server 2005 which has a date time field.
SQL Server 2005 I have an SQL Function (ftn_GetExampleTable) which returns a table with
i have a database table which contains some fields. one of the field's value
I have a table in sql server 2005 which holds an ip range and
I have 2 records in a table in SQL Server 2005 db which has
I have a table in SQL Server 2005 with a variable number of columns,

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.