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 June 18th, 2003, 11:13 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to notChavez
Default Hexadecimal numbers in MS SQL Server 7

I'm trying to create a web-based application that will allow us to store and access all of the information we need for our customer support department using PHP and MS SQL Server.

What I need to know is whether or not I can have MS SQL Server 7.0 SP4 automatically generate a hexadecimal number, either as a stored procedure or whatever.

Thanks in advance for any help.


There was a time when this was all funny to me.
 
Old June 18th, 2003, 11:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Certainly. You could convert an identity value to hex, or use the random number generator. In the end you just want a random number and to convert it to hex. Remember it doesn't make much difference whether the number is in hex or decimal, that is just a format for the number.

If you want the number as a hex _string_ that may be a little more difficult.

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

Just to reply to myself:

You could return the value as type varbinary. See the following proc:

Code:
CREATE PROCEDURE GetHex
@HexRet VarBinary(2) OUTPUT
AS

SET @HexRet = CAST(CAST((RAND()*255) AS Int) AS VarBinary(2))
regards
David Cameron
 
Old June 19th, 2003, 08:07 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to notChavez
Default

David,
Great! Thanks! That's exactly the sort of thing I was looking for.



There was a time when this was all funny to me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
MS SQL Server license dk6607 SQL Server 2005 1 February 7th, 2008 07:32 PM
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
MS Access to SQL server connection imaley Access VBA 3 February 16th, 2007 01:59 PM
MS SQL Server Replication rodmcleay SQL Server 2000 2 August 12th, 2004 02:33 AM





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