belleisa_net
Messages postés1Date d'inscriptionmardi 20 mars 2007StatutMembreDernière intervention29 mai 2007
-
29 mai 2007 à 21:29
GURDOUS
Messages postés25Date d'inscriptionmercredi 10 mars 2004StatutMembreDernière intervention18 décembre 2008
-
5 juin 2007 à 20:50
Bonjour à vous tous,
J'aimerais avoir votre expertise pour pouvoir régler mon problème. J'ai un champ (nvarchar) dans un table et lors du select je voudrais que si la longueur du champ n'est pas égal à 6 caractères remplacer le nombre de caratères manquants par une *.
Je vous donnes un exemple:champ NoCoupon '1245' devrait donner NoCoupon '1245**'
Voici ce que j'avais trouvé jusqu'a maintenant :
select
case(len(vcnumerocoupon
))
when 6
then vcnumerocoupon
else
'******'
end
as vcnumerocoupon
from validercoupon
GURDOUS
Messages postés25Date d'inscriptionmercredi 10 mars 2004StatutMembreDernière intervention18 décembre 2008 5 juin 2007 à 20:50
au fait tu sur qlq system,
si tu es salserver, pense a utiliser les fonction,
voila le pricincipe
lCREATE FUNCTION formatChaine (@typ nvarchar)
RETURNS nvarchar
AS
begin
declare @formatChaine nvarchar
declare @nbcar integer
declare @i integer
set @nbcar=len(@typ)
set @formatChaine=@typ
if @nbcar<6
begin
while len(@formatChaine)<6
begin
set @formatChaine=@formatChaine + '*'
end
end
return @formatChaine
End
select dbo.formatchaine(nom_champ) as coupon from table
bonne chance