Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Break value in 1 colunm to populate 3 columns

Author  Topic 

justjohno
Starting Member

23 Posts

Posted - 2006-12-14 : 20:38:57
New to T-SQL any help would be appreciated. I need to take first 3 characters of column "a" (xxx-xxxxx-xxx) and put into column "b". Take the next 5 characters from and put into column "C" and take the next 3 characters in put into column "D". If anyone can point me in a direction or help me with this would greatly be appreciated.
Thanks

John O

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-12-14 : 21:24:21
Look at string functions in Books Online (sql server help). Specifically the function: Substring

update myTable set [b] = substring(a, 1, 3), [c] = substring(a, 4, 5), etc...


Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-14 : 23:24:30

1 If it just for display, you can split and show them and no need of other three columns
2 If you use front end application, you can use Split function there
3 or also read about parsename in sql server help file



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -