Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9148167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:12:03+00:00 2026-06-17T11:12:03+00:00

I have a column called ‘CLIENTDATA’ in table CLIENTDET and have a data like

  • 0

I have a column called ‘CLIENTDATA’ in table CLIENTDET and have a data like ‘last-ST – Tranactions – Challan Details – Int. Calc. – Interest Report – N’.

Case 1:

When i write a query

SELECT CLIENTDATA,
       LEN(CLIENTDATA)
FROM   CLIENTDET  

In this case i am getting correct data and length as ’75’.

Case 2:

When i write a query

SELECT CAST(
           CASE 
                WHEN CLIENTDATA IS NULL THEN ''
                ELSE CLIENTDATA
           END AS 
           VARCHAR
       ),
       LEN(
           CAST(
               CASE 
                    WHEN CLIENTDATA IS NULL THEN ''
                    ELSE CLIENTDATA
               END 
               AS VARCHAR
           )
       )
FROM CLIENTDET

In this case i am not getting correct data as in Case 1, here length is '30'.

Anything i am missing here or not understood?…. Image is attached

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:12:05+00:00Added an answer on June 17, 2026 at 11:12 am

    When you cast a literal to character type without specifying the length,
    by default it is 30.
    So you need to specify the enough column length when you use character datatypes.
    Ref.
    and here msdn reference

    e.g.

    Declare @a varchar(100)
    Select @a='123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
    
    Select LEN(CAST(@a as Varchar)),LEN(@a)
    

    as additonal information

    When declaring a VARCHAR variable without defining the length, it will default to 1.

    DECLARE @a VARCHAR
    SET @a = 'ABCDE'
    SELECT @a 
    

    Returns: “1”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column called cached_votes_up in Communities table. Now I'd like to fetch
I have a column called DayShift in a table which is of Yes/No data
I have a column called THE_VALUE in a table TABLE_A , that holds data
I have a column called location and it has data in it like: texas_dallas
i have a table called orders and i have a column called Last Update
In database table I have column called options . It has type of integer
I have this column called code that look like : 1-100-ETC-60 , 1-100-ETC-20 ,
I have the column DateTimeExpired, and I would like to create another column called
I have two tables A and B. Table A have a column called a_value
In the table, I have a column called as BillDate (Datetime) . The datetime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.