How to write a SQL Server 2008 SQL stat't to populate a 3 character Branch field with the COSTCENTER field starting at position 4?

Posted on 2014-10-28
Last Modified: 2014-10-28
I am using SQL Server 2008.
How would you write a SQL   UPDATE statement to populate the
BRANCH field, a 3 character field. The source would be the 4th position (up to 3 characters in length) of the COSTCENTER field.

for ex:

UPDATE dbo.tblPSEmail
Question by:zimmer9
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 69

Accepted Solution

Scott Pletcher earned 500 total points
ID: 40409276
Honestly, I wouldn't, I'd use a computed column for Branch.

ALTER TABLE dbo.tblPSEmail

If there might be only 1 or 2 bytes, and you need to zero-fill them, you could do this:

ALTER TABLE dbo.tblPSEmail

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

717 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