Quantcast
Channel: t-sql question
Browsing latest articles
Browse All 11 View Live

t-sql question

Hi sqldev,If all records in your table are numeric then I guess the simplest solution is:SELECT col=CONVERT(Int, col)FROM #t1This one will also not remove the trailing 0's, like REPLACE...

View Article



t-sql question

sure Brad, but how about if there are spaces at the end like '   0001700     '  in this case it will not workUnderstood... but he only mentioned leading spaces and zeroes.You're right... if he had to...

View Article

t-sql question

sure Brad, but how about if there are spaces at the end like '   0001700     '  in this case it will not work

View Article

t-sql question

A bit tricky...Premature optimization is the root of all evil in programming. (c) by Donald Knuth Naomi Nosonovsky, Sr. Programmer-Analyst My blog

View Article

t-sql question

brad it will fail in case there is zero at the end like '00001700'No it won't... try it!(I only did a LTRIM... I did NOT do an RTRIM, so those ending zeroes will be restored by the second...

View Article


t-sql question

SELECT * FROM #t1 select case when FirstNumberPosition > 0 then substring(col,FirstNumberPosition, LEN(col)) else col end from ( select patindex('%[1-9]%',col) as FirstNumberPosition, col from #t1)...

View Article

t-sql question

declare @String varchar(30) set @String = ' 00001705' select case when FirstNumberPosition > 0 then substring(@String,FirstNumberPosition, LEN(@String)) else @String end from ( select...

View Article

t-sql question

brad it will fail in case there is zero at the end like '00001700'

View Article


t-sql question

Here's one way...SELECT REPLACE(LTRIM(REPLACE(Col,'0',' ')),' ','0')FROM #T1That will first replace all zeroes with a space, then do the LTRIM, then replace all the spaces with zeroes again.--Brad (My...

View Article


t-sql question

select ltrim(rtrim(col)) from #ti

View Article

t-sql question

I have data in my table with leading spaces and then zero's. I want to trim the leading spaces and even the zero's and just grab the rest of the number. Below is sample dataCreate table #t1(col...

View Article
Browsing latest articles
Browse All 11 View Live




Latest Images