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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:44:04+00:00 2026-05-12T20:44:04+00:00

I am working on a legacy database. I am not able to change the

  • 0

I am working on a legacy database. I am not able to change the schema 🙁 in a couple of tables the primary key uses multiple columns.

In the app I read the data in each row into a table the user then updates the data and I write the data back into the table.

Currently I concatenate the various PK columns and store them as a unique id for when I put the data back into the table.

Now I was wondering if there is a more efficient way to do that. Coming from a mySQL background I am not aware of any but thought SQL Server 2005 may have a function

SELECT PRIMARYKEY() as pk, ...  FROM table WHERE ... 

the above would select the key that the database engine uses as the primary key for the given record

I searched and couldn’t find anything. Its probably just me being fussy but I don’t like the concatenation trick.

DC

  • 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-12T20:44:04+00:00Added an answer on May 12, 2026 at 8:44 pm

    In SQL Server, there is no equivalent of PRIMARYKEY() that I would be aware of, really. You can consult the system catalog views to find out which columns make up the primary key, but you can’t just simply select the primary key value(s) with a function call.

    I would agree with StarShip3000 – what do you concatenate your PK values for? While I don’t think a compound primary key made up of several columns is necessarily a very good idea, if it’s a legacy system and you can’t change it, I wouldn’t bother concatenating the PK values on read, and then having to split them apart again when you write your data back. Just leave the structure as it is – compound keys aren’t generally recommended, but they are indeed supported, no problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm so surprise while I'm working in Fluent NHibernate. I got my legacy database
I'm working on a legacy app and for whatever reason it's trying to stuff
I have been working on some legacy C++ code that uses variable length structures
I'm working with a legacy database that stores GUID values as a varchar(36) data
I need to access a legacy relational database via ActiveRecord and that database uses
I'm working with a legacy database which due to poor management and design has
I am working with legacy systems at the moment, and a lot of work
I am working on a legacy project in VC++/Win32/MFC . Recently it became a
I am working on a legacy ASP application. I am attempting to insert a
We are working with some legacy code that accesses a shared drive by the

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.