Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 25th, 2006, 02:24 PM
Registered User
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default counting characters in a field

i'm a news.

but i am trying.

within a certain field (urlref), i am trying to truncated just the everything left of the '?'.

a typical entry in this record for this field would be: ("http://www.foreexample.com?steven@steven.com")

i know i would have to:

get count of characters in the whole string x

find where ? character is charindex('?',URLref)

get count y after ?

subract y from x

i'm confusing myself.

Old August 26th, 2006, 12:35 AM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

My sql is not flash but ill give it a go:

;;;i am trying to truncated just the everything left of the '?'.
you want the cars before the ? or the chars after the ?

;;;get count of characters in the whole string x
I dont believe you need the length of the whole string

;;;subract y from x
You can append strings however do not believe you can subtract

This will give you all the characters left of the ?:
SELECT LEFT(URLref,CHARINDEX('?', URLref)-1) from tblName

Wind is your friend

Similar Threads
Thread Thread Starter Forum Replies Last Post
counting characters from a textbox ayem Visual Studio 2008 2 October 7th, 2009 10:40 PM
Less than 10 characters in field arholly Access 2 December 14th, 2006 01:58 PM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 05:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.