Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql substr problem

Author  Topic 

fortheempire
Starting Member

1 Post

Posted - 2010-06-21 : 07:55:15
a question from an exam i did

in sql, substr ('HELLO WORLD', 1, 3) produces the string 'Hel'

now it was true or false, and i put down true cause i thought substr starts from the first number, and goes the 2nd number of characters. ie, it finds the first character ('H') and goes 3 characters exclusive, so it grabs 'hel'. i got this wrong, dont understand why?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-21 : 08:01:04
1. In T-SQL substr() is unknown but SUBSTRING() is known.
2. select substring('HELLO WORLD', 1, 3) gives 'HEL' and not 'Hel'




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-21 : 08:44:34
Maybe it is not a exam on SQL Server ?
Maybe it is an Oracle exam ?
And maybe for Oracle, substr() returns the string in lower case ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-21 : 08:49:11
And MAYBE then his answer wouldn't be wrong?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-21 : 09:34:41
Good point


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -