January 21, 2009 at 11:14 am
Please create the test table I used, with the insert I used, in the database you are testing, and run your copy of the code on that. See if it finds the other rows besides just the one with the char(31) in it. Or have you already done that?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 21, 2009 at 11:48 am
agh100 (1/21/2009)
Hi GSquared,I have been sick for some days now, so I haven't been able to try your script until now.. And thanks very much, it works splendidly on SQL 2005 not on 2000 since "coalesce" doesn't exists. But never mind... I will just import a copy of my database to 2005, and run the script on it...
Thanks very very much....
Kind regards,
Anders
Heh... you better check again... COALESCE works just fine in SQL Server 2000. If you don't think so, look it up in the 2k BOL... it's there.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 22, 2009 at 1:13 am
Hi GSquared,
I have run the code on the Test1 table you sendt.. And i can see that it contains the char values.. But it only returns char31....
For the "fun of it" I tried changing the value of @char31 to :
SELECT @char31 = char(35)
Now the code will only find char(35)'s... For some reason the query does not work with the interval :
' like ''%[' + @Char0 + '-' + @Char31 + ']%'''
Perhaps I should just make it with a lot of OR clauses... like ''%[' + @Char0 + ']%''' or like ''%[' +@char1 + ']%''' ..... and so forth...
Sorry for posting the thread wrong in the first place, I didn't notice it... But now I am using SQL 2005...
Mvh
Anders
January 22, 2009 at 7:20 am
Aha! It's losing the first bracket in the query, per the print results. Try changing that to "[[", see if it gets what you need.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 23, 2009 at 1:55 am
It wasn't... 🙁 ....
I am still pretty sure, that for some reason, the interval @char0 - @char31 is not correctly interpreted for some reason... It will still only "look" at the last variable @char31... (or the last one entered)...
' like ''%[' + @Char0 + '-' + @Char1 + ']%'''
shows me only char(1) values
' like ''%[' + @Char0 + '-' + @Char2 + ']%'''
shows me only char(2) values
I don't understand how you can make it work when I cannot...
January 23, 2009 at 2:28 am
Could it have anything to do with the version of SQL server I am using??!
For test purposes I am using SQL Express 2005 9.0.1399...
Kind regards,
Anders
January 23, 2009 at 7:27 am
Try this:
create table #T (
ID int identity primary key,
Col1 char(10));
insert into #T (Col1)
select '1' union all
select 'a';
select *
from #T
where Col1 like '%[a-z]%';
See what that gives you.
If it's not working for you, it's more likely an issue with collation than with server version.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 26, 2009 at 1:55 am
It works...
I got everything to work now... Strangely enough, it will not return values from 0-31 but it works from 1-31...
So if i change the code to:
declare @Char0 char(1), @Char31 char(1), @sql nvarchar(max);
select @Char0 = char(1), @Char31 = char(31);
It works... I don't understand, cause I was convinced that I had tested it... But I guess I didnt.. Cause it works 😉
Sorry for taking so much of your time Gsquared, you have been very helpful and patience with me... Thanks...
Kind regards,
Anders
January 26, 2009 at 7:19 am
Glad I could help.
I can understand why char(0) wouldn't work, since it's basically the lack of a character.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 26, 2009 at 7:42 pm
CHAR(0) is the NULL character... remember what happens with nulls... same thing here.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 16 through 25 (of 25 total)
You must be logged in to reply to this topic. Login to reply