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.
| Author |
Topic |
|
havey
Starting Member
16 Posts |
Posted - 2009-01-29 : 19:37:41
|
| Hi i have data in a column like so: 0x54583D302E3435here is a sample from 3 records0x54583D302E34350x54583D322E32350x54583D302E3639I'm not sure what "encoding" is used but i figured out that the decimal values that these represent are in a pattern. For example0x54583D302E3035=0.00x54583D352E3133=5.1here is the first one broken down:0x54583D3 0 2E3 0 35=0.0the second:0x54583D3 5 2E3 1 33after this part: 0x54583D3 the whole number exists until2E3 then the decimal exists.Question: does anyone know the excoding this isor how would a function look to extract these numbers, here is my ill attempt, thanksDECLARE @Value NVARCHAR(200)DECLARE @FirstSet NVARCHAR(6)DECLARE @SecondSet NVARCHAR(6)SET @Value = '0x54583D302E3035'SET @FirstSet = REPLACE('0x54583D3', SUBSTRING(@Value, PATINDEX('%[^0-9]%', @Value), 1), '')SET @SecondSet = REPLACE('0x54583D3'+FirstSet, SUBSTRING(@Value, PATINDEX('%[^0-9]%', @Value), 1), '')SET @Value = @FirstSet + '.' + @SecondSetSELECT @Value |
|
|
Raibeart
Starting Member
8 Posts |
Posted - 2009-01-30 : 10:48:03
|
| What is the data type of he original column? |
 |
|
|
kseabolt
Starting Member
2 Posts |
Posted - 2009-01-30 : 12:19:13
|
| These look like varbinary data to me. Try this:select convert(varchar(7),0x54583D302E3435)select convert(varchar(7),0x54583D322E3235)select convert(varchar(7),0x54583D302E3639)Results:TX=0.45TX=2.25TX=0.69Do those values make any sense to you? |
 |
|
|
havey
Starting Member
16 Posts |
Posted - 2009-01-30 : 19:06:20
|
thansk kseabolt, right you are. |
 |
|
|
|
|
|
|
|