SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Upgrading from Access to Sql Server2005-vba functions


Upgrading from Access to Sql Server2005-vba functions

Author
Message
sarahs
sarahs
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
nick.hoare
nick.hoare
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search