Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update Statment

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2009-01-02 : 10:13:24
In my Select Query I took out the "-" in the zipcode with this statment below....

replace(impact_prod.dbo.pro.pro_zip,'-','') AS [Zip],

How can I use this same statement in an update statement for my Billing Zip code. This is what I have......

Update #MonthEndProviders
Set #MonthEndProviders.[Billing Zip] = replace([Billing Zip],'-','')

Would this work? Let me know, thanks!

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-01-02 : 10:14:57
yes

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 10:15:54
what happened when you tried to run it?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 10:19:43
Whats the datatype of [Billing Zip]? unless its text or ntext you can use REPLACE. if text of ntext, you need to use method below

http://www.sqlteam.com/article/search-and-replace-in-a-text-column
Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2009-01-02 : 10:24:17
Thank you!

quote:
Originally posted by elancaster

yes

Em

Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-01-02 : 10:28:02
quote:
Originally posted by visakh16

Whats the datatype of [Billing Zip]? unless its text or ntext you can use REPLACE. if text of ntext, you need to use method below

http://www.sqlteam.com/article/search-and-replace-in-a-text-column




true, but in this case they already said it worked as a select statement

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 10:55:41
quote:
Originally posted by elancaster

quote:
Originally posted by visakh16

Whats the datatype of [Billing Zip]? unless its text or ntext you can use REPLACE. if text of ntext, you need to use method below

http://www.sqlteam.com/article/search-and-replace-in-a-text-column




true, but in this case they already said it worked as a select statement

Em


but the field they gave in select statement was different (it was impact_prod.dbo.pro.pro_zip not #MonthEndProviders.[Billing Zip])
Go to Top of Page
   

- Advertisement -