Unix Technical Forum

Stored Procedure

This is a discussion on Stored Procedure within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I want to change the data in a few fields of a table. There are many records (about ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:36 PM
Shwetabh
 
Posts: n/a
Default Stored Procedure

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:37 PM
Dan Guzman
 
Posts: n/a
Default Re: Stored Procedure

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@gmail.com> wrote in message
news:1141734360.018259.125170@i40g2000cwc.googlegr oups.com...
> 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
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 07:37 PM
Shwetabh
 
Posts: n/a
Default Re: Stored Procedure

Thanks a million Dan, it works like a charm!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com