RE: Removing zeros

RE: Removing zeros

 

  

SELECT CAST(REPLACE('00070065', '0','') AS INT)

-----Original Message-----
From: John Thomas [mailto:[Email Address Removed] Thursday, June 19, 2003 6:25 PM
To: LazyDBA.com Discussion
Subject: RE: Removing zeros


Shouldn't it be the other way around? Convert it to Integer and then back to
Character? I would assume what he has is char/varchar expression / column.

select convert(char,convert(int, '00765'))

-----Original Message-----
From: Horton, Joe (LNI) [mailto:[Email Address Removed]
Sent: Thursday, June 19, 2003 10:20 AM
To: LazyDBA.com Discussion
Subject: RE: Removing zeros

That would suck though if your number was 00070065 - would then be 765
instead of 70065 - REPLACE here would be bad - CONVERT or CAST to string
value - then back to INT would be easiest.

___________________________
Joe Horton
Database Developer / Software Engineer
WISHA/Legal Services Software Development
Department of Labor and Industries
Voice (360) 902-5928 fax (360) 902-6200

-----Original Message-----
From: Julia Poddoubsky [mailto:[Email Address Removed]
Sent: Thursday, June 19, 2003 9:32 AM
To: LazyDBA.com Discussion
Subject: RE: Removing zeros

Look at replace function in BOL:

replace (column_name, '0', '') will replace all zeroes with nothing.

Julia

-----Original Message-----
From: Usman Farhat [mailto:Usman.[Email Address Removed] Thursday, June 19, 2003 1:40 AM
To: LazyDBA.com Discussion
Subject: Removing zeros


Hi Everyone,

In SQL Server if there is any function to remove leading zeros.
For example if we have expression 00765 . Function should
result in 765.

Thanks,
Usman


--------------------------------------------------------------------
NOTA CONFIDENZIALE:
Questo messaggio ed i suoi allegati sono indirizzati esclusivamente
alle persone indicate in testa e possono contenere informazioni
confidenziali. Se avete ricevuto il messaggio per sbaglio, sappiate
che qualunque utilizzo improprio del contenuto è proibito, Vi
preghiamo quindi di inoltrarlo immediatamente al mittente e di
cancellare il messaggio. Per qualsiasi informazione vi inivitiamo a
contattarci scrivendo a [Email Address Removed]

Grazie

CONFIDENTIALITY NOTICE:
This message and its attachments are addressed solely to
the persons
above and may contain confidential information. If you
have received
the message in error, be informed that any use of the
content hereof
is prohibited. Please return it immediately to the sender
and delete
the message. Should you have any questions, please contact us
by replying
to [Email Address Removed] you
--------------------------------------------------------------------

---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed] REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed] REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed] electronic transmission is strictly confidential and intended solely
for the addressee. It may contain information which is covered by legal,
professional or other privilege. If you are not the intended addressee,
you must not disclose, copy or take any action in reliance of this
transmission. If you have received this transmission in error,
please notify the sender as soon as possible.

This footnote also confirms that this message has been swept
for computer viruses.
**********************************************************************

MS Sql Server LazyDBA home page