Viewing 15 posts - 21,496 through 21,510 (of 26,484 total)
I came up with another option, and I think it is easier. It uses patindex to find the first non-zero character.
select substring(@varstr,patindex('%[^0]%', @varstr),len(@varstr) - patindex('%[^0]%', @varstr) + 1)
April 14, 2009 at 9:39 pm
I guess not enough people complained about the answer to this question.
April 14, 2009 at 9:32 pm
I have to agree with Jeff. This was an awesome thread and it demonstrates what a community can do when it works together for a common purpose. Hats...
April 14, 2009 at 8:31 pm
See if you can use this code to strip leading zeros and if it helps your query.
declare @varstr nvarchar(50);
set @varstr = '000045691823';
select substring(@varstr,patindex('%[A-Za-z1-9]%', @varstr),len(@varstr) - patindex('%[A-Za-z1-9]%', @varstr) + 1)
set @varstr...
April 14, 2009 at 4:39 pm
You should still be able to use the code sample above to develop a solution to your problem at work.
April 14, 2009 at 4:04 pm
Bruce W Cassidy (4/14/2009)
[font="Verdana"]Didn't RBarryYoung's article start a little bun fight! It will be fun to watch. Brave, brave man.[/font]
Looks like another "cursor man" out there if you...
April 14, 2009 at 3:42 pm
May I suggest you read this article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
April 14, 2009 at 3:33 pm
Does this help?
create table dbo.xtable (
ID int,
val1 varchar(30) null,
val2 varchar(30) null
);
create table #tmp (
ID...
April 14, 2009 at 3:30 pm
gbechar (4/14/2009)
unfortunately I am writing from home and have no Internet at work.Yes , I need to update exsiting data
Well, you need to provide a clearer picture of what you...
April 14, 2009 at 3:25 pm
GilaMonster (4/14/2009)
Bruce W Cassidy (4/14/2009)
[font="Verdana"]I took a lesson from St Lynn. Not sure it will help, but worth a shot.[/font]I'm not even sure what the question is any longer.
Not...
April 14, 2009 at 3:22 pm
Still confused. One, the formatting doesn't allow me to easily see what is in what column. Also, Are we updating existing data? Your original post really did...
April 14, 2009 at 3:03 pm
GilaMonster (4/14/2009)
<Sigh>http://www.sqlservercentral.com/Forums/Topic696113-92-1.aspx
Three years experience, asking questions like this? More like 1 month of experience over 36 months.
April 14, 2009 at 1:40 pm
RBarryYoung (4/14/2009)
Manie Verster (4/14/2009)
RJ, I hope you don't mind but I'm going to jump in here. Barry, maybe RJ's requirements is small enough to justify a distribution list but every...
April 14, 2009 at 1:37 pm
GilaMonster (4/14/2009)
Lynn Pettis (4/14/2009)
Gail, see the latest on this one you were just on?
I saw it. I had a half-written, very snarky reply that I deided was better not posted....
April 14, 2009 at 1:28 pm
Okay, try this instead:
create table dbo.xtable (
ID int,
val1 varchar(30) null,
val2 varchar(30) null
);
create table #tmp (
...
April 14, 2009 at 1:24 pm
Viewing 15 posts - 21,496 through 21,510 (of 26,484 total)