Solved

How can I run a function on a database column?

Posted on 2016-09-06
5
29 Views
Last Modified: 2016-09-07
I have a function that removes all special characters etc on insert/update. I want to run this function on an existing column so it will go through every entry in the table and remove the special characters on a specific column. Can someone tell me how I can accomplish this?
Thank you!
0
Comment
Question by:earwig75
  • 2
  • 2
5 Comments
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 250 total points
ID: 41786178
Should be an UPDATE then. Something like this:
UPDATE TableName
SET ColumnName = MyFunction(ColumnName)

Open in new window

0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 41786274
How large is the table?  Do you have sufficient time and log space to handle changing all rows in a single UPDATE?  Can you afford to have the table unavailable to any other task until the UPDATE completes?
0
 

Author Comment

by:earwig75
ID: 41786388
There are 380,000. I've never done this before so I'm not sure how long it would take. Do you have any idea of an estimate? Would it take longer than 5 minutes? Thanks.
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 250 total points
ID: 41786424
Depends on server speed and how long each column is.  If the data is 100 bytes or less, I'd expect not.  If it's 8000 bytes or more, I'd expect it would take more than 5 minutes.

Also, you need to pre-allocate enough log space to handle the update.  If the log has to grow dynamically, the entire db pauses while the log is extended (and, as a secondary concern with that, you can physically fragment the log file, somewhat slowing future processing).
0
 

Author Comment

by:earwig75
ID: 41788261
Thank you for the help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

706 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

19 Experts available now in Live!

Get 1:1 Help Now