dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: SQL
Expertise: Beginner
Nov 24, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Find and Replace a String in a Table

The folowing stored procedure will find and replace a string in a table:

CREATE PROCEDURE [dbo].[sp_st_FindANDReplaceString]
@Tablename  varchar(20),
@FieldName  varchar(20),
@FindString  varchar(30),
@RepalceString  varchar(30)
AS

declare @sqlstring varchar(8000)

Select  @sqlstring  = "Update " +  @Tablename + " Set " +  @FieldName + "
= Replace(" + @FieldName + ",'" +  @FindString + "','" + @RepalceString  +
"')"

execute (@sqlstring)
GO

EXEC sp_st_FindANDReplaceString ('Orders','ShipName','QUICK','SLOW')
This replaces QUICK to SLOW in the field ShipName of the Orders table.
Dinesh Asanka
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date