October 14, 2009 at 9:50 am
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??
October 14, 2009 at 12:20 pm
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.
October 15, 2009 at 2:04 am
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?
January 13, 2015 at 11:35 pm
update table1 set col1 = dbo.fnRemoveBadCharacter(col1);
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply