Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

My blog on SQL Server, TSQL, MSBI and other areas of SQL Server.
Browse by Tags · View All
Cube in Sql Server.. 2
RollUp 2
Groupby 2
Use of NULLIF 2
Procedures 2
Search Objects (Table Name 2
Happy diwali 1
SP_Rename 1
Bulk Insert 1
Completed 4 Years in IT Profession......................................... 1

Archive · View All
May 2012 10
June 2012 7
October 2012 3
July 2012 2
November 2012 1
September 2012 1

Please give Answer without use of SSMS(Substring knowledge)

Jul 13 2012 12:00AM by Nirav Gandhi   

HI,
To know your Substring Function Understanding power give answer without use of Query builder and SSMS.

select Substring('Nirav',1,4)

select Substring('Nirav',-2,4)

select Substring('Nirav',4,-2)

Please send me your answers ..i m waiting u r answers.


Tags: Substring,String comapre


Nirav Gandhi
38 · 5% · 1503
5
 
 
 
0
Learned
 
0
Incorrect



Submit

4  Comments  

  • Hello, Nirav!

    Here you go:

    Statement 01: select Substring('Nirav',1,4)

    The output is 'Nira' - SQL Server will start from the 1st character, and return a total of 4 characters. (Please note that unlike C++ or other programming languages, string manipulation in SQL Server does not use a 0-based index)

    Statement 02: SELECT SUBSTRING('Nirav',-2,4)

    This is same as the Statement 01. If the start position is negative, SQL Server gracefully handles this scenario and starts from the beginning of the string.

    Statement 03: SELECT SUBSTRING('Nirav',4,-2)

    The length has to be a positive integer. Since the length parameter here is (-2), SQL Server will generate an error (which one, I don't know because for that I would have to use SSMS :))

    By the way - this would make a good T-SQL Interview question. You may want to repost this one (or provide a link to this post) in the Interview Questions module of the site (http://beyondrelational.com/modules/17/interview-questions.aspx?s=stream&tab=interview-questions).

    commented on Jul 14 2012 2:00PM
    Nakul Vachhrajani
    4 · 33% · 10575
  • HI,Nakul

    Statement 02 and Statement 01 not give same output.

    commented on Jul 16 2012 12:13AM
    Nirav Gandhi
    38 · 5% · 1503
  • @Nirav: Agree. Another look at Books-On-Line cleared the formula.

    Statement 02: SELECT SUBSTRING('Nirav',-2,4)

    If the start position is negative, SQL Server gracefully handles this scenario and starts from the beginning of the string. However, the number of characters returned are (start position + length - 1), which in this case evaluates to (-2 + 4 -1) = 1.

    The output will therefore be 'N'

    commented on Jul 16 2012 1:16AM
    Nakul Vachhrajani
    4 · 33% · 10575
  • yes..u r right..

    Thanks for give answer....

    commented on Jul 16 2012 1:47AM
    Nirav Gandhi
    38 · 5% · 1503

Your Comment


Sign Up or Login to post a comment.

"Please give Answer without use of SSMS(Substring knowledge)" rated 5 out of 5 by 5 readers
Please give Answer without use of SSMS(Substring knowledge) , 5.0 out of 5 based on 5 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]