Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select query calling userdefined function

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2007-06-28 : 16:27:39
If i call the following userdefined function via select query:

select (dbo.ccsFunctionRecipientTO(29,'RM'))

it is getting the record/data, but with no Column Name to it, i need the columnname as ToField

All i did is this:

select (dbo.ccsFunctionRecipientTO(29,'RM')) as ToField

I am getting an error message:
Incorrect syntax near the keyword 'TOField'


Here is my userdefinedfunction:
**********************************************************************
CREATE FUNCTION [dbo].[ccsFunctionRecipientTO](@ModuleID integer, @ModuleName VARCHAR(10))
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @s VARCHAR(8000)
SET @s=''
SELECT @s=@s + [Name] + char(13)
from TAB_ccsNetRecipients where ModuleRecordID = @ModuleID and ModuleName = @ModuleName and RecipientType = 'TO'
If @s IS NOT NULL AND @s <> ''
BEGIN
SELECT @s = left(@s, Datalength(@s)-1)
END
ELSE
BEGIN
SELECT @s = ''
END
Return @s

**********************************************************************

Please help thank you very much for the information.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-28 : 18:49:31
Is that all you have or do you have more of the SELECT statement that you did not post here..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -