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

user defined functions & columns Expand / Collapse
Author
Message
Posted Wednesday, October 14, 2009 9:50 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 27, 2010 8:09 AM
Points: 28, Visits: 35
I have created a user defined function that takes a string as input.
EG: Create function func_new(@str varchar(20))
returns varchar(20)
begin
......
.....

return @str1
end

@str is a table column
How do I call this function so that all columns in the table get manipulated by the function??
Post #802880
Posted Wednesday, October 14, 2009 12:20 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:31 PM
Points: 6,841, Visits: 13,358
Please provide more information on what you're trying to do.
It's hard for us to translate
"......
.....
"
into something that "manipulates all columns in the table"

We don't even know what table you're talking about nor what kind of "manipulation" you're trying to do.

Please follow the first link in my signature on how to post sample data and I'm sure you'll get fast response that actually will answer your question.

Keep in mind that we don't see what you see since we can't look over your shoulder.




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #803011
Posted Thursday, October 15, 2009 2:04 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 27, 2010 8:09 AM
Points: 28, Visits: 35
Create FUNCTION [dbo].[fnRemoveBadCharacter]
(
@BadString nvarchar(40)
)
RETURNS nvarchar(40)
AS
BEGIN

DECLARE @nPos INTEGER
SELECT @nPos = PATINDEX('%[^a-zA-Z0-9_]%', @BadString)

WHILE @nPos > 0
BEGIN
SELECT @BadString = STUFF(@BadString, @nPos, 1, '')
SELECT @nPos = PATINDEX('%[^a-zA-Z0-9_]%', @BadString)
END


This is the function I have created to remove bad characters.

How do I call this function to update col1(nvarchar(40)) of tbl1 to remove bad characters?
Post #803275
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse