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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 substring error

Author  Topic 

psangeetha
Yak Posting Veteran

95 Posts

Posted - 2010-08-25 : 10:41:00
Hi friends,

Here is the table I'm doing the select on



select name, pwd from test

name(varchar) pwd(varchar)
-----------------------------------
Mary At connect

select CAST(datalength(name) AS VARCHAR) + substring (pwd,3,6) from test;
4 conne


But I need the result to be '4 con' (length of test.name + 3rd to 6th character in test.pwd inluding the space)

Please help...

Thank you

Kristen
Test

22859 Posts

Posted - 2010-08-25 : 10:46:56
From documentation:

SUBSTRING(string, start, length)

not

SUBSTRING(string, start, end_position)
Go to Top of Page
   

- Advertisement -