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

  • Home
  • SEARCH
  • 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 7519781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:57:33+00:00 2026-05-30T01:57:33+00:00

I have a SQL question that I could use some help with. Still somewhat

  • 0

I have a SQL question that I could use some help with. Still somewhat new to SQL and not too sure how or if this can be done, but I am betting it can.

I have table A that contains a few columns. One in particular, colTxt has a long list of string text that in some cases is a duplicate of another record in the same table/colTxt.

Another column is blank and is intended to store the keyID of a second table (table B) which needs to be created from the string text mentioned above, but without duplicates.

So in some cases, records in table A will reference the same keyID of table B, because the string text was the same in table A. (foreign Key)

I need to build table B dynamically in the SQL. I think I have the table create sequence figured out, its the copying of the string from Table A into table B = tblStringText, and posting the ID back to Table A that has me stuck.

CREATE TABLE [dbo].[tblStringText](
[ID] [int] IDENTITY(1,1) NOT NULL,
[tblROOTKey_ID] [smallint] NULL,
[Short_Text] [nvarchar](255) NULL

CONSTRAINT [PK_ID] PRIMARY KEY CLUSTERED 
(
[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,      ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


GO

any help on this would be appreciated.

  • 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-30T01:57:34+00:00Added an answer on May 30, 2026 at 1:57 am

    Asuming tblStringText is your ‘Table B’ and the column ‘Short_text’ should contain the matching strings, this might accomplish what you want:

    INSERT INTO tblStringText(Short_Text)
    SELECT DISTINCT colTxt
    FROM  tableA
    
    UPDATE tableA
    SET    keyID = tblStringText.Id
    FROM   tblStringText
    WHERE  tableA.colTxt = tblStringText.Short_Text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a short question. Im my current project I'm using LINQ-to-SQl. That is
I have an SQL question which may be basic to some but is confusing
I have this question in which I have a SQL Server Compact Edition database
This is sort of SQL newbie question, I think, but here goes. I have
This question might be kind of elementary, but here goes: I have a SQL
I have a question about SQL Server indexes. I'm not a DBA and assume
I have a similar question to this one SQL products/productsales I want to do
Using SQL Server 2008. This is a really junior question and I could really
T-SQL DateTime Question. I have a set of time ranges. During those time ranges
I have quick question for you SQL gurus. I have existing tables without primary

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.