Programming in sql: Split string on embedded character on newest questions tagged sql – Stack Overflow

I have a master table that I am inserting data into from an import temp table. The data doesnt require alot of massaging, but one column that does is one that deals with dimensions. The dimensions I record is length, width and height. They are three separate columns, varchar(10) in each.

The import table has these combined into one column, delimited by an “x”, so LxWxH.

Ultimately I am writing this transformation into an executable stored procedure, but I’m getting stuck on this split. Can someone give me a hand on how to code this?

The template of my insert is:
Assuming master table is ID (int), Length varchar(10), width varchar(10), height varchar(10)
Assuming import table is ID (int), Dims varchar(50)

Data looks like (from import) :

1   1.2x3.5x9.5
2   2.4x3.5x8.5
etc etc

The code:

insert into [mastertable]
id, length, width, height
select
from [importtable]

Any help is appreciated! The SQL Server version is 2008.

See Answers


source: http://stackoverflow.com/questions/11286847/split-string-on-embedded-character
Programming in sql: programming-in-sql



online applications demo