으로 변환합니다. this question (Sql Server convert integer to binary string과 비슷하지만 대신 varbinary (16)를 해당 텍스트 버전으로 변환하고 싶습니다.SQL Server varbinary (16)을 이진 텍스트
나는 내 코드의 결과가 증명할 수있는 무언가를 비극적으로하고 있습니다.
create function GetGuidBinaryString (@value varbinary(16))
returns varchar(128)
as
begin
declare @vsresult varchar(128)
declare @inti int
select @inti = 128, @vsresult = ''
while @inti>0
begin
select @vsresult=convert(char(1), @value % 2)[email protected]
select @value = convert(int, (@value/2)), @[email protected]
end
return @vsresult
end
create table #values (binvalue varchar(128))
delete from #values
declare @intcount int
select @intcount = 0
while @intcount < 100
begin
insert into #values select dbo.GetGuidBinaryString(convert(varbinary(16),convert(bigint,2147483640) + @intcount))
select @intcount = @intcount+1
end
select * from #values
아마 함수가 양수로만 올바르게 작동하기 때문에 함수에서 수행중인 암시 적 변환이있을 수 있습니다.
건배. 전체 범위를 얻으려면 CLR 함수를 만들어야합니다. – Nat