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
 SQL Server Development (2000)
 substring/patindex

Author  Topic 

misterzr
Starting Member

49 Posts

Posted - 2007-06-19 : 11:37:53
I have a column that i need to update and strip out some unwanted characters, the table is testdta.f4101 and the column is IMDSC2. The column contains data that has a - in it and I need to strip out everything before the -. Here is an example of the data in that field( TB_DSC_M - 1X12), I need it to update to - 1X12 in the same column. There are various lengths of data but they all contain the -. Is using the substring with patindex the way to go here



sshelper
Posting Yak Master

216 Posts

Posted - 2007-06-19 : 12:02:47
Aside from using SUBSTRING and CHARINDEX/PATINDEX, you can also use the PARSENAME function by replacing the '-' with a period. Here's an example on how PARSENAME can be used to split a string (in the link provided, it uses a space as the separator but you can easily replace this with a dash):

http://www.sql-server-helper.com/tips/split-name.aspx

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -