Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how can i rename a picture name stored in a table

Posted on 2013-06-28
4
Medium Priority
?
272 Views
Last Modified: 2013-06-28
Hi

I have a database with a table named myimages, this contains a field named imagepath which is an ntext datatype.

Imagepath contains the names of several thousand images a lot of which end in .tif

I want to rename the .tif files to be .png

How can I do this?

when I tried

SELECT
 replace([imagePath],".tif",".png")
     
  FROM [mydatabase].[dbo].[myImages]
  where imagepath like '%.tif'

I received an error message.

Can anyone help me with the syntax to update the table?
0
Comment
Question by:Nemetona
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Zberteoc earned 2000 total points
ID: 39284926
update [mydatabase].[dbo].[myImages] set
	[imagePath]=replace([imagePath],".tif",".png")
where
	[imagePath] like '%.tif'

Open in new window

0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 39284929
The error probably stems from the double quotes. SQL Server uses single quotes.
If that is just a type-o in the question here, please post the error you are receiving.

As an aside, if there is a possibility that someone named a file with '.tif' in the name, you may want to consider taking the first part of the string minus the last four characters, then just add '.png' to the end.
0
 
LVL 27

Expert Comment

by:Zberteoc
ID: 39284934
Yes, I missed to change the " to '.  Actually I was editing my first post but I could'n save it due to already posted message above. So the update should be:

update [mydatabase].[dbo].[myImages] set
	[imagePath]=replace([imagePath],'.tif','.png')
where
	[imagePath] like '%.tif'

Open in new window

0
 

Author Closing Comment

by:Nemetona
ID: 39285128
Thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question