varchar(8) query

  • hi guys, can someone tell me how can i query a query to give me the rows in which the lenght is bigger than 8?

  • select (column list)

    from dbo.Table

    where len(column) > 8

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Be aware that LEN does not count trailing spaces.

    SELECT LEN('abc') -- 3

    SELECT LEN('abc ') -- 3

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • thank you!! exactly what i need, just to confirm my column is nvarchar(8), then i could use your code to see which rows will not truncated if i use the import wizard (from another sql table), correct?

  • Yup. Should be fine.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • thank you!!!!:D

  • sorry, another question, how do i get the first 8 characters?

  • SELECT LEFT(<Some Column>,8) FROM ....

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • thank youuuuuuuu!!!!

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply