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 2008 Forums
 Transact-SQL (2008)
 Delete Character

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2011-02-23 : 21:10:40
Hi guys,

I have sample data like this
R43567
J45678

Question:- I want to delete R & J front of each rows. Please guide me how i can fix this issue. Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-23 : 21:29:28
You want to delete only R and J or all of the first characters?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

chris_n_osborne
Starting Member

34 Posts

Posted - 2011-02-23 : 21:39:06
[code]
CREATE TABLE #test
(textcol NVARCHAR(6)
)
go

INSERT INTO #test
(textcol
)
SELECT 'R43567' UNION ALL
SELECT 'J45678'
go

SELECT * FROM #test
UPDATE #test
SET textcol =
CASE
WHEN LEFT(textcol, 1) = 'R' THEN RIGHT(textcol, 5)
WHEN LEFT(textcol, 1) = 'J' THEN RIGHT(textcol, 5)
END
SELECT * FROM #test
go



textcol
-------
R43567
J45678


textcol
-------
43567
45678
[/code]
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2011-02-24 : 00:11:12
All First Characters and i have 65k rows in my table.
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-24 : 00:14:13
is this what you are looking for?

Select Substring(ColumnName,2,len(ColumnName)) From TableName



Cheers
MIK
Go to Top of Page
   

- Advertisement -