Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 July 18th, 2003, 03:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default retrieve numerice value from nvarchar

Hi,

How can retrieve numeric value from the nvarchar data type.

contractno. (field nvarchar)
-------------------------
000
001
00a
050
02d
78b
090c
305d
659f

and so on....

select * from contract where contractno between '01' and '100'

above query retrieve three digit records between 01 to 100
I want to retrieve record between 1 to 100

if I want to retrieve records between a to z what query will use ?

what query will use in above two condition, please help.
I am using sql server with asp.

Mateen
[email protected]
 
Old July 18th, 2003, 04:06 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

select * from contract where contractno like '%[a-z]%'
will give you the values containing a to z

Could you give more detail on the 1st point.

e.g. do you want only values with numbers ranging from 1 - 100 and not 001 for example.

Regards

Nickie
 
Old July 18th, 2003, 11:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for youre response.
I want to retrieve records ranging from 001 - 100 .
because records are save 001, 009, ......

retrieve actuall range records not retrieve out of
range records.

Mateen


Quote:
quote:Originally posted by nbryson
 Hi

select * from contract where contractno like '%[a-z]%'
will give you the values containing a to z

Could you give more detail on the 1st point.

e.g. do you want only values with numbers ranging from 1 - 100 and not 001 for example.

Regards

Nickie
 
Old July 20th, 2003, 06:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It appears that if there are characters in the column, then they are always at the end of the string. Is this the case?

regards
David Cameron
 
Old July 20th, 2003, 11:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes


Quote:
quote:Originally posted by David Cameron
 It appears that if there are characters in the column, then they are always at the end of the string. Is this the case?

regards
David Cameron
 
Old July 20th, 2003, 11:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This may be a little slow due to the LIKE, but it should be OK.

Code:
UPDATE MyTable
SET MyCol = LEFT(MyCol, LEN(MyCol) - 1)
WHERE RIGHT(MyCol, 1) LIKE '[^0-9]'
regards
David Cameron
 
Old July 21st, 2003, 03:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for help

Quote:
quote:Originally posted by David Cameron
 This may be a little slow due to the LIKE, but it should be OK.

Code:
UPDATE MyTable
SET MyCol = LEFT(MyCol, LEN(MyCol) - 1)
WHERE RIGHT(MyCol, 1) LIKE '[^0-9]'
regards
David Cameron





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert from nvarchar(25) to smalldatetime aspless SQL Language 6 September 14th, 2007 09:21 AM
'AddedBy' NVARCHAR field - inefficient? holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 January 18th, 2007 07:38 PM
convert nvarchar to money smatyk SQL Server 2000 2 October 26th, 2006 06:37 PM
change nvarchar to varchar vincentc SQL Server 2000 3 May 24th, 2005 10:56 PM
Convert int to nvarchar bekim SQL Language 1 August 12th, 2004 06:33 AM





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