Hot answers tagged

6

Eithers of these 3 should work: SELECT color , HEX_1 = '#' + CONVERT(varchar(6), CAST(ABS(color) as varbinary(1)) + CAST(ABS(color/256) as varbinary(1)) + CAST(ABS(color/256/256) as varbinary(1)) , 2) , HEX_2 = '#'+ +CONVERT(varchar(2), CAST(ABS(color) as varbinary(1)), 2) ...


4

The biggest number you can fit into numeric(5,2) is 999.99. Therefore 123.556... is fine, but 1234.556... is too big. You can find the rules for truncation, rounding, and errors during implicit conversions in the documentation: CAST and CONVERT (Transact-SQL) I don't know SQL-server that well, so I don’t know if you can configure the behaviour. One idea ...


1

For anybody who may come across this problem, I solved using this function: -- Description: Converts ARGB to RGB(RR,GG,BB) -- e.g. 16744703 returns RGB(255,128,255) or #FF80FF CREATE FUNCTION [dbo].[ARGB2RGB] (@ARGB AS BIGINT,@ColorType AS VARCHAR(1)) RETURNS VARCHAR(16) AS BEGIN DECLARE @Octet1 TINYINT DECLARE @Octet2 TINYINT ...



Only top voted, non community-wiki answers of a minimum length are eligible