I have a large text file that will be loaded into a temp table. The file will have sample text like below,
We the People of the United States@ in Order to form a more perfect Union@ establish Justice@ insure domestic Tranquility@ provide for the common defense@ promote the general Welfare@ and secure the Blessings of Liberty to ourselves and our Posterity@ do ordain and establish this Constitution for the United States of America@
I want to extract the text that appears before each "@" symbol and insert each extracted line into separate records in a temp table.
CREATE TABLE #Test
(
SerialNumber VARCHAR(10),
Text VARCHAR(MAX)
);
After extracting the string the text should be inserted into the temp table.
So far, this is the code I can think of, Need help to extract the remaining text and insert it into the temp table.
DECLARE @test nvarchar(max)
SET @test = 'We the People of the United States@ in Order to form a more perfect Union@ establish
Justice@ insure domestic Tranquility@ provide for the common defense@ promote the general
Welfare@ and secure the Blessings of Liberty to ourselves and our Posterity@ do ordain and
establish this Constitution for the United States of America@'
SELECT
'1' AS SerialNumber,
LEFT(@test, CHARINDEX('@', @test) - 2) AS Text;
Thanks in advance!