dbTalk Databases Forums  

Stored Procedure

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


Discuss Stored Procedure in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shwetabh
 
Posts: n/a

Default Stored Procedure - 03-07-2006 , 06:26 AM






Hi,

I want to change the data in a few fields of a table.
There are many records (about 1k+). All I want to do to
these fields is to append a string to the starting of data in the
fields.
eg:

Old Data ->

---------------------------
Image
---------------------------
A1.jpg
A2.jpg



Required data ->


-----------------------------
Image
----------------------------
\Images\A1.jpg
\Images\A2.jpg





For this purpose, should I use a procedure or is there any other
possible way out?

Awaiting your replies,
Regards
Shwetabh


Reply With Quote
  #2  
Old   
Dan Guzman
 
Posts: n/a

Default Re: Stored Procedure - 03-07-2006 , 06:48 AM






Try:

UPDATE MyTable
SET ImagePath = '\Images\' + ImagePath

This can be encapsulated in a stored procedure if needed:

CREATE PROC dbo.UpdateImagePath
@ImagePathPrefix varchar(255)
AS
UPDATE MyTable
SET ImagePath = @ImagePathPrefix + ImagePath
GO

EXEC dbo.UpdateImagePath '\Images\'

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Shwetabh" <shwetabhgoel (AT) gmail (DOT) com> wrote

Quote:
Hi,

I want to change the data in a few fields of a table.
There are many records (about 1k+). All I want to do to
these fields is to append a string to the starting of data in the
fields.
eg:

Old Data -

---------------------------
Image
---------------------------
A1.jpg
A2.jpg



Required data -


-----------------------------
Image
----------------------------
\Images\A1.jpg
\Images\A2.jpg





For this purpose, should I use a procedure or is there any other
possible way out?

Awaiting your replies,
Regards
Shwetabh




Reply With Quote
  #3  
Old   
Shwetabh
 
Posts: n/a

Default Re: Stored Procedure - 03-07-2006 , 09:30 PM



Thanks a million Dan, it works like a charm!


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.