January 30, 2008 at 10:39 am
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
January 31, 2008 at 11:00 am
I think you need a Computed Column. Have a look at this article http://www.sqlservercentral.com/articles/User-Defined+functions/complexcomputedcolumns/2397/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply