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.
| Author |
Topic |
|
fedupjohn
Starting Member
6 Posts |
Posted - 2012-08-29 : 08:30:30
|
| I'm new to this site but read it often.Here is what I haveE:\HostingSpaces\Name\NameLess.com\wwwroot\portals\0\In_Bound_Faxes\25I have fax to email service sending me emails.The "I" in "In_Bound" is actually the 64th position in the stringThe number at the end is the actual name of the file.To view this file in an HTML module I need 'In_Bound_Faxes\25'.The number 25 will grow in length as this unfolds.I know how to parse a static length string but not a dynamic length string.When I do this:Select Left (FaxLocation,64) as Fax_Name from dbo.cf_FaxLocation .This returns me the first 64 characters.If I do this:Select Right (FaxLocation,17) as Fax_Name from dbo.cf_FaxLocationI works, but, once the file name changes length I'll be dropping a leading character.I could use a little helpJohn Hornak |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-08-29 : 09:09:35
|
| DECLARE @str varchar(100) = 'E:\HostingSpaces\Name\NameLess.com\wwwroot\portals\0\In_Bound_Faxes\25'select SUBSTRING(@str,54,100)JimEveryday I learn something that somebody else already knew |
 |
|
|
fedupjohn
Starting Member
6 Posts |
Posted - 2012-08-29 : 09:21:34
|
Thanks Jim,This is what I didSelect SUBSTRING(FaxLocation,63,4000) as Fax_Name from dbo.cf_FaxLocation where ID = @IDIt returned me '\In_Bound_Faxes\25'Just what I neededquote: Originally posted by jimf DECLARE @str varchar(100) = 'E:\HostingSpaces\Name\NameLess.com\wwwroot\portals\0\In_Bound_Faxes\25'select SUBSTRING(@str,54,100)JimEveryday I learn something that somebody else already knew
John Hornak |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-29 : 09:43:17
|
This is another way to do it!Select SUBSTRING(FaxLocation,63,datalength(FaxLocation)) as Fax_Name from dbo.cf_FaxLocation where ID = @ID --------------------------Joins are what RDBMS's do for a living |
 |
|
|
|
|
|
|
|