Hi AllI have a function that will replace from a column that contains just one value but now I need to to find a value from a list of colours so if the colour is found it replaces it with '' here is the other version for the single columnAmy help would be well appreciated :)ALTER function [dbo].[UfnLikeColour](@Value varchar(max)) returns varchar(max) asbegindeclare @returnstring varchar(max) set @returnstring = lower(@Value) declare @i int set @i = ascii('a') while @i <= ascii('z') begin set @returnstring = replace( @returnstring, ' ' + char(@i), ' ' + char(@i-32)) set @i = @i + 1 end set @returnstring = CASE WHEN char(ascii(left(@returnstring, 1))-32) + right(@returnstring, len(@returnstring)-1) IN ( 'AliceBlue','AntiqueWhite','Aqua','Aquamarine','Azure','Beige','Bisque','Black','BlanchedAlmond','Blue','BlueViolet','Brown','BurlyWood','CadetBlue','Chartreuse','Chocolate','Coral','CornflowerBlue','Cornsilk','Crimson','Cyan','DarkBlue','DarkCyan','DarkGoldenRod','DarkGray','DarkGreen','DarkKhaki','DarkMagenta','DarkOliveGreen','DarkOrange','DarkOrchid','DarkRed','DarkSalmon','DarkSeaGreen','DarkSlateBlue','DarkSlateGray','DarkTurquoise','DarkViolet','DeepPink','DeepSkyBlue','DimGray','DodgerBlue','FireBrick','FloralWhite','ForestGreen','Fuchsia','Gainsboro','GhostWhite','Gold','GoldenRod','Gray','Green','GreenYellow','HoneyDew','HotPink','IndianRed ','Indigo ','Ivory','Khaki','Lavender','LavenderBlush','LawnGreen','LemonChiffon','LightBlue','LightCoral','LightCyan','LightGoldenRodYellow','LightGray','LightGreen','LightPink','LightSalmon','LightSeaGreen','LightSkyBlue','LightSlateGray','LightSteelBlue','LightYellow','Lime','LimeGreen','Linen','Magenta','Maroon','MediumAquaMarine','MediumBlue','MediumOrchid','MediumPurple','MediumSeaGreen','MediumSlateBlue','MediumSpringGreen','MediumTurquoise','MediumVioletRed','MidnightBlue','MintCream','MistyRose','Moccasin','NavajoWhite','Navy','Nude','OldLace','Olive','OliveDrab','Orange','OrangeRed','Orchid','PaleGoldenRod','PaleGreen','PaleTurquoise','PaleVioletRed','PapayaWhip','PeachPuff','Peru','Pink','Plum','PowderBlue','Purple','RebeccaPurple','Red','RosyBrown','RoyalBlue','SaddleBrown','Salmon','SandyBrown','SeaGreen','SeaShell','Sienna','Silver','SkyBlue','Skin Tone','SkinTone', -- --- --- make this with the space'SlateBlue','SlateGray','Snow','SpringGreen','SteelBlue','Tan','Teal','Thistle','Tomato','Turquoise','Violet','Wheat','White','WhiteSmoke','Yellow','YellowGreen','Assorted Colours','Black Combination','Black Currant','Black/Nude','Black/Pink','Black/Pink Ash','Black/Skin','Black/White','Blossom','Bluebell','Blush','Botanical','Cappuccino','Caramel','Champagne','Cherry Red','Deep Blue','Emerald','Flamenco','Floral Print','Grape','Grey','Holly Berry','Ivory / Skin','Ivory/Floral','Ivory/Pink','Ivory/Rose','Leopard Print','Lollipop','Midnight Blue','Mocha','Monochrome','Navy Floral','Neon','Neon Pink','Nude Beige','Nude/Pink','Peppermint','Pink Paradise','Powder','Raspberry','Rebel','Rose','Rose Pink','Sea Breeze','Skin','Skin/Light','Smooth Skin','Spearmint','Tangerine','Vanille','White/Print','White/Skin Tone' ) THEN char(ascii(left(@returnstring, 1))-32) + right(@returnstring, len(@returnstring)-1) ELSE 'No Colour' END return @returnstringend
↧