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 2000 Forums
 Transact-SQL (2000)
 Char

Author  Topic 

kemi2299
Starting Member

41 Posts

Posted - 2008-04-28 : 10:24:23

hi,

could you pls help me out to change to tsql statement, can't seem to get anywhere.

thanks

n3=LEFT(RIGHT(CHAR(NHS_Num,15,1),

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-28 : 10:27:54
quote:
Originally posted by kemi2299


hi,

could you pls help me out to change to tsql statement, can't seem to get anywhere.

thanks

n3=LEFT(RIGHT(CHAR(NHS_Num,15,1),


Post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-28 : 10:28:51
You may want to have


n3=LEFT(RIGHT(CHAR(NHS_Num),15),1),

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-28 : 10:37:46
SELECT SUBSTRING(CAST(NHS_Num AS VARCHAR(8000)), LEN(NHS_Num) - 14, 1)


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kemi2299
Starting Member

41 Posts

Posted - 2008-04-28 : 12:23:40
hi guys,

thanks for your help,
I run this statement and i get the error statement below
n3=LEFT(RIGHT(CHAR(NHS_Num),15),1),


The conversion of the varchar value '4628174520' overflowed an int column. Maximum integer value exceeded.


the second solution is not running.
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2008-04-28 : 12:31:26
I don't understand what you are trying to do. NHS numbers are always 10 digits long.

http://www.connectingforhealth.nhs.uk/systemsandservices/nhsnumber
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-28 : 12:32:02
Seems like n3 is an integer column to which you're assiging value of a varchar column. The value happens to be outside range of integer data type. So based on your requirement either make n3 bigint datatype or keep it as varchar itself.
Go to Top of Page
   

- Advertisement -