|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, January 24, 2012 8:25 AM
Points: 3,
Visits: 24
|
|
We are in the process of upgrading from MS Access to Sql as there have been instances when records have not been appended and lost due to the very large sized tables.
I have this function that removes extra misc symbols from a model number field so that the model number can be just plain characters and numbers. I need to know how to convert this function to sql so that I can use it in a view. Do I create a user defined function or a stored procedure and how would I reference it in the view?
Thanks, Sara
This is the code I have in access:
Public Function RemvChar(modelNum) tmp = modelNum If IsNull(tmp) Then tmp = "" 'tmp = "aa bb-cc/dd\ee" 'model# tmp = Replace(tmp, "-", "") tmp = Replace(tmp, " ", "") tmp = Replace(tmp, "/", "") tmp = Replace(tmp, "\", "") tmp = Replace(tmp, ",", "") tmp = Replace(tmp, "*", "") tmp = Replace(tmp, "+", "") tmp = Replace(tmp, "#", "") tmp = Replace(tmp, "?", "") tmp = Replace(tmp, "(", "") tmp = Replace(tmp, ")", "") tmp = Replace(tmp, "_", "") tmp = Replace(tmp, ".", "") tmp = Replace(tmp, "”", "") tmp = Replace(tmp, "’", "") tmp = Replace(tmp, "&", "") tmp = Replace(tmp, ";", "")
newtmp = tmp RemvChar = newtmp End Function
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, March 19, 2009 9:39 AM
Points: 4,
Visits: 7
|
|
| I think you need a Computed Column. Have a look at this article http://www.sqlservercentral.com/articles/User-Defined+functions/complexcomputedcolumns/2397/
|
|
|
|