4,707 questions
Hi,
Convert it first to varbinary and then varchar like this:
select max(RV),CONVERT(varchar(max),convert(VARBINARY(100),max(RV)),1) from testbinary
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I'm running 2017 and the following script isnt returning a varchar visual of my binary(8) column. I tried different sizes and a sub select but nothing works...i'll post the image next. I got the approach from https://stackoverflow.com/questions/45051735/convert-binary-to-varchar
USE [research]
drop table testbinary
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestBinary](
[Id] [int] IDENTITY(1,1) NOT NULL,
Testcolumn char(1),
[RV] rowversion,
CONSTRAINT [PK_TestBinary] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
insert testbinary (testcolumn) select 'y'
select max(RV),convert(varchar(max),max(RV),1) from testbinary
Hi,
Convert it first to varbinary and then varchar like this:
select max(RV),CONVERT(varchar(max),convert(VARBINARY(100),max(RV)),1) from testbinary
this is an image of the result set returned
master.[sys].fn_varbintohexstr