May 20, 2002 at 9:54 am
Hi, I'm sure this is an easy one...
I'd like to get the correct T-SQL syntax for selecting the data I want only if the string length is > 10, else I want it to be NULL. Please let me know if this is even close, if not, any suggestions would be appreciated. Thx
IF (SELECT ColumnA FROM tblOld
WHERE LEN(ColumnA) > 10)
BEGIN
(SELECT ColumnA FROM tblOld)
END
ELSE ColumnA IS NULL
May 20, 2002 at 9:57 am
That works, but I'd do
select
case when len ( cola) > 10
then colA
else null
end 'colA'
Steve Jones
May 20, 2002 at 11:12 am
Thanks. I found the column was 'text' not varchar...a little more work involved. I'm open for other options if you know of a quicker way than declaring a variable to pass the data into or using a temp table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply