Solved

how can i rename a picture name stored in a table

Posted on 2013-06-28
4
265 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
  • 2
4 Comments
 
LVL 26

Accepted Solution

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

Open in new window

0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
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 26

Expert Comment

by:Zberteoc
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Dynamics crm 2011 8 43
Extract XML Data from using TSQL 5 27
SQL Select Query help 3 29
Calculating Business Hours 19 59
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now