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)
 ASCII decimal code function

Author  Topic 

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-25 : 01:58:49
Hi All,

I am using SQL Server 2005.
I want to get ASCII decimal code of the first character in a string, is there any function like this.

For Ex: if a function is there like this : function name('ABC')

this should return 65

thanks you very much

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-03-25 : 02:02:19
Try this:

Declare @Test Varchar
set @Test ='Sample'

Select ascii(left(@Test,1))

Regards,
Bohra
I am here to learn from Master and help new bees in learning.
Go to Top of Page

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-25 : 02:03:55
Thank you very much
Go to Top of Page

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-25 : 02:09:55
Declare @Test Varchar
set @Test ='Sample'

Select ascii(@Test)

This is also working
Thanks
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-03-25 : 02:09:58
Write you own function

Create function [dbo].Convert_Ascii(@input_string varchar(100))
returns int
as
begin
return ascii(left(@input_string,1))
End

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

asuni
Yak Posting Veteran

55 Posts

Posted - 2010-03-25 : 02:10:31
ya this is also fine thanks you very much
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-03-25 : 02:14:33
welcome
Go to Top of Page
   

- Advertisement -