dbTalk Databases Forums  

How write this sentence with T-SQL

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss How write this sentence with T-SQL in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
simonshang@gmail.com
 
Posts: n/a

Default How write this sentence with T-SQL - 07-18-2007 , 12:56 PM






Hi, all friends. I'm using SQL-SERVER 2000.I have a table like this:
NIF Name
----------------------------------------
A-1234 Company1
B-123-B1 Company2
C-4568 Company4
D-453-DF Company5

I want delete the symbol "-" in the row "NIF". eg. A-1234 change to
A1234, D-453-DF to D453DF

So how can I write the sentence . Should I use the Stored Procedure?
Thank you very much!!
Simon


Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: How write this sentence with T-SQL - 07-18-2007 , 02:26 PM






On Wed, 18 Jul 2007 10:56:05 -0700, simonshang (AT) gmail (DOT) com wrote:

Quote:
I want delete the symbol "-" in the row "NIF". eg. A-1234 change to
A1234, D-453-DF to D453DF
Hi Simon,

SELECT REPLACE(NIF, '-', '')
FROM YourTable;

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis


Reply With Quote
  #3  
Old   
Ed Murphy
 
Posts: n/a

Default Re: How write this sentence with T-SQL - 07-18-2007 , 07:48 PM



Hugo Kornelis wrote:

Quote:
On Wed, 18 Jul 2007 10:56:05 -0700, simonshang (AT) gmail (DOT) com wrote:

I want delete the symbol "-" in the row "NIF". eg. A-1234 change to
A1234, D-453-DF to D453DF

Hi Simon,

SELECT REPLACE(NIF, '-', '')
FROM YourTable;
Or, if you want to change the data in the table (not just the
data in your query output):

UPDATE YourTable
SET NIF = REPLACE(NIF, '-', '')


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.