Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Upgrading from Access to Sql Server2005-vba functions Expand / Collapse
Author
Message
Posted Wednesday, January 30, 2008 10:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #449546
Posted Thursday, January 31, 2008 11:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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/
Post #450100
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse