Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does substring take smaller size than specified

Status
Not open for further replies.

mariayx

Programmer
May 18, 2001
17
0
0
US
I use SUBSTRING(@data_string, 12, 17) to get a substring from the following whole string '140PTOHCO 2DTT707904 CCONTINENTAL AIRLINES 460120030822 N'
But instead of getting '2DTT707904', I got only '2DTT707'. Can someone help?
Thanks,
mariayx
 
Maybe the variable you are using to hold the new substring element is not define to 12 characters ... try this ...

declare @test VarChar(20)

SET @Test = SUBSTRING('140PTOHCO 2DTT707904 CCONTINENTAL AIRLINES 460120030822 N', 12, 17)

print @test

Thanks

J. Kusch
 
Thanks!
That's exactly what has happened.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top