Strange Experience in MSSQL Server with ‘substring’ and ‘len’ Functions

As of all DBA a me too is a great FAN of MS SQl Server for its Flexibility, stability and versatility , though recently i experienced a strange walthrough while i was into simple string functions with length and Substring extractions

my requirement is simple one to extract a portion from a defined string , for this i have to use length of another defined string and use it as first parameter

in detail…

select substring(‘abcdefgh’,1,1)

this will return ‘a’

now insted of first ’1′ i replace length of string function as below

select substring(‘abcdefgh’,len(‘b’),1)

ir returned a null

how this happened….

But again when i tried on a different machine it worked well , i am still in a dialema how the first one happened and at that time all the procedures written was not with this kind of line but i am pretty sure it happened

  • Meet Author

    S.Abhilash, started this blog in the later half of 2009 as a self hosting site for all his previous blogging attempts. , My way of writing and frequency of publishing may not be uniform as my resources are my projects nd issues i came across. For the last few years this blog is reacing 100 s of unique visitors each day, thanks wordpress and google for such a perfection in their software and services.

    Head to Authors Page | Abhilash on Facebook



Category MSSQL Server     Tags , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Comment on Facebook

Comments are closed.

Community



FREE News Letter

Enter your email address

See Also

Resources

Please Submit your Email Address to Get Latest Technology News As it Happens


Enter your email address


Read previous post:
Meego Operating System

On February 15, 2010, the world’s largest chip manufacturer, Intel, and the world’s largest mobile handset manufacturer, Nokia, announced joining...

Close