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.
Asuming tblStringText is your ‘Table B’ and the column ‘Short_text’ should contain the matching strings, this might accomplish what you want: