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.
| Author |
Topic |
|
dumbdumb
Starting Member
5 Posts |
Posted - 2004-03-16 : 23:18:33
|
| Hi all,All this is in store procedure.How do I search for whether an input parameter conatain at least one upper case? Return true if there is else return false. |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-03-16 : 23:36:00
|
| [code]--create tally table for the functionset nocount oncreate table dbo.numbers ( n int primary key)declare @n int ; set @n = 1while @n <=255 --max length of input parameterbegin insert into numbers select @n set @n = @n + 1endGO--Inputdeclare @input varchar(20)set @input = 'hello'--Functiondeclare @bool bitset @bool = 0IF EXISTS ( select 1 from dbo.numbers where n <=len(@input) and convert(binary,(UPPER(substring(@input,n,1)))) = convert(binary,substring(@input,n,1)) and substring(@input,n,1) like '[A-Z]')set @bool = 1select @boolGO[/code] |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2004-03-16 : 23:50:33
|
If you are using SQL2K you can leverage the COLLATE function...DECLARE @T VARCHAR(1000)SET @T = 'asdfasdfs'IF PATINDEX('%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE latin1_general_cs_as, @T) > 0 PRINT 'OK'ELSE PRINT 'No'--ORIF @T LIKE '%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE latin1_general_cs_as PRINT 'OK'ELSE PRINT 'No'EDIT: The LIKE version.....DavidM"An Ugg Boot is a generic Australian term that has been in use for nearly 100 hundred years. Now some coporate wanker has trademarked it.. " |
 |
|
|
dumbdumb
Starting Member
5 Posts |
Posted - 2004-03-17 : 00:56:30
|
HiHey thanks ya! Your code works! Hmm....but now I have another problem, This chunk of code does not work when applying for symbol!Symbol definition : Any character that is not alphanumeric and numberDECLARE @T VARCHAR(1000)SET @T = 'asdfasdfs'IF PATINDEX('%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE latin1_general_cs_as, @T) > 0 PRINT 'OK'ELSE PRINT 'No'--ORIF @T LIKE '%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE latin1_general_cs_as PRINT 'OK'ELSE PRINT 'No'EDIT: The LIKE version.....DavidM"An Ugg Boot is a generic Australian term that has been in use for nearly 100 hundred years. Now some coporate wanker has trademarked it.. "[/quote] |
 |
|
|
|
|
|
|
|