CHARINDEX ( SearchString , ColumnToSearch [ , start_location ] )
SUBSTRING ( _expression_ , start , length )
here's a sample
--[ CODE ]---------------------------------------------------------------------------------
SET NOCOUNT ON
-- Create Temp Table
SELECT TOP 0 Cast('' as varchar(30)) CODE into #TABLE
-- Insert Dummy Data
Insert INTO #TABLE Select '0000023674 - V5'
Insert INTO #TABLE Select '0000023674 - V6'
Insert INTO #TABLE Select '0000023674 - V7'
Insert INTO #TABLE Select '0000023674 - V8'
-- Get the number you wanted
SELECT SubString(CODE, CharIndex('V',CODE)+1, 1) As Number
FROM #TABLE
DROP TABLE #TABLE
SET NOCOUNT OFF
--[ /CODE ]---------------------------------------------------------------------------------
On Wed, 27 Oct 2004 08:33:58 +0800, miss_mystikal
<[EMAIL PROTECTED]> wrote:
>
>
>
> Hi, how to split data like this:
>
> 0000023674 - V4
>
> I want to get the number after 'V'.
>
> Can we do it in SQL? I have one table and they are thousand records with
> similar id.
>
> Instead of using loop in VB, is there any other way to cut the number?
>
> To unsubscribe, send an email to:
> [EMAIL PROTECTED]
>
>
>
>
>
> Yahoo! Groups Sponsor
>
> ADVERTISEMENT
>
>
> ________________________________
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/PlanetSourceCode/
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.762 / Virus Database: 510 - Release Date: 9/13/2004
>
To unsubscribe, send an email to:
[EMAIL PROTECTED]
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/PlanetSourceCode/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
