Solved

how can i rename a picture name stored in a table

Posted on 2013-06-28
4
268 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
ID: 39284926
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
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 26

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 35
SQL trigger 5 20
SQL USE DATABASE VARIABLE 5 27
RESTORE MASTER DATABASE -- NOW 2 17
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 …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

808 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