Hello, I have a table that I created from a flat file. Not very normalized as you can see:
ID TEXT -- ---- 1 This is just 1 some sample text 1 that I am using 2 Here is some 2 more of it 3 and yet some more
I have thousands of records. What is my best approach to normalize this into ..
ID TEXT -- ---- 1 This is just some sample text that I am using 2 Here is some more of it 3 and yet some more
I would like to keep the multiple lines of text, but put them into one field. Please help. Thanks.
There are two approaches you could try. First is to pre-process your flat file before loading. Simple idea, yes?
The second approach is to concatenate the multiple lines into one using a GROUP BY query with a special function for this purpose. MySQL has the GROUP_CONCAT function, Sybase ASA has the LIST function, and there may be similar functions in other databases. Check under aggregate functions in your documentation.
There's another way, which is to write a stored procedure using a cursor, but that's far more difficult than the first approach.
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback. Continue Reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clause Continue Reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.