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 2000 Forums
 SQL Server Development (2000)
 At least 3 characters?

Author  Topic 

SqlZ
Yak Posting Veteran

69 Posts

Posted - 2002-03-01 : 12:10:28
I have a variable named and declared @A.

How do I find if @A is at least 3 characters long?

Something like
IF @A< char(3)
BEGIN
Print 'small'
END
ELSE
BEGIN
Print 'bigger than char(3)'
END

This is probably very easy to do but I can't find out how.

Thanks.


========================
My username represents the two things that consume most of my time.
SQL, and my Z

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-03-01 : 12:15:59
Use len()


DECLARE @A varchar(50)

SET @A = 'Hi'

IF len(@A) < 3
BEGIN
Print 'small'
END
ELSE
BEGIN
Print 'bigger than char(3)'
END


SET @A = 'Yaks are cool'

IF len(@A) < 3
BEGIN
Print 'small'
END
ELSE
BEGIN
Print 'bigger than char(3)'
END

Michael

Go to Top of Page

SqlZ
Yak Posting Veteran

69 Posts

Posted - 2002-03-01 : 12:18:21
Thank you very much. :)

I knew it was something simple.

========================
My username represents the two things that consume most of my time.
SQL, and my Z
Go to Top of Page
   

- Advertisement -