I want to开发者_如何学运维 find and replace in all db fields which contains a link in my database?how is that possible?
I have more tables but i don't know which tables :),i need to search programmatically.
I need to a method,example,GetContainsaLink(dbname) it should returns me tables and which field contains a link,
I have already a dictionary map old and new link for changing.
Example:
old link in a db field :images/123/789/picture/9D/10006685.jpg
new link in a db field :images/345/8001/picture/9D/10006685.jpg
Dump your from -> to mapping into a new table, and perform updates such as the below:
UPDATE MLT
SET link = LM.newlink
FROM mylinktable MLT
INNER JOIN linkmap LM
ON LM.oldlink = MLT.link
...to find which fields need updating - now that requires some knowledge of the data you're storing. A query such as SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%link%'
may be useful here.
精彩评论