Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Add a / in the middle of string

Posted on 2014-08-13
2
Medium Priority
?
94 Views
Last Modified: 2014-08-13
I need to be able to insert a / in the middle of a string, so this 125674567 ends up like this 12/567/4567.

I am using SQL Server 2005.
I have used the SUBSTRING Function to display this, as below:
SELECT
    SUBSTRING(Holding, 1, 2) + '/' +
    SUBSTRING(Holding, 3, 3) + '/' +
    SUBSTRING(Holding, 6, 11)
      FROM TagOrder_Import_RawData

How would I be able to update the records in the table?

Any help would be appreciated
Thnaks
0
Comment
Question by:Morpheus7
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 40258654
Unless I'm missing something here...
UPDATE TagOrder_Import_RawData
SET Holding = 
    SUBSTRING(Holding, 1, 2) + '/' +
    SUBSTRING(Holding, 3, 3) + '/' +
    SUBSTRING(Holding, 6, 11) 

Open in new window

Disclaimer:  HOLY GOD MAKE A BACKUP FIRST, and you can't sue me if this goes wrong.
0
 

Author Closing Comment

by:Morpheus7
ID: 40258688
Many thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question