Øyvind Isaksen
Øyvind Isaksen

Reputation: 195

SET value in SQL using LEN function

I need to set @Type = '0' if (LEN(@Token) < 65. How do I do that?

Upvotes: 0

Views: 218

Answers (1)

squillman
squillman

Reputation: 13641

Remove the outer parentheses.

IF LEN(@Token) < 65 SET @Type = '0';

Example:

DECLARE @token VARCHAR(100);
DECLARE @Type VARCHAR(100) = '1';

SET @token = 'asdfasdfaf';

IF LEN(@Token) < 65 SET @Type = '0';

PRINT @Type;

Upvotes: 3

Related Questions