how to switch names to numbers for insert statement
Posted on 2012-08-14
This was a difficult question for me to figure out how to word, but the problem is that I have three tables set up like this.
Statement (TopicID int identity(1,1), text varchar(500), modifiedDate datetime)
Topic( Topic_Code int identity (10,10), topicName varchar(150))
Statement_Topics (TopicID, TopicCode)
Statement_Topics is the go between table between topic and Statement. I was given a list of data in excel format that contains all of the Statements and there corresponding topics seperated by a ; in this format.
Topic_ID Text Topic(s)
# blah blah blah topic1; topic2;
# blah blah blah topic5; topic6
However, I am unsure how to get all of this information into my tables correctly.
I was able to load the excel data into a table called database$ and from there I was able to get all of the seperate topics into the topic table. At this point I need to basically say if the topicID corresponds to topic1 and topic 2 then put topic1;topic2 in the database.
I need to fill out the Statement_Topics table and i'm not sure how to do this. Can anyone help me out with some ideas?