0
[SqlProcedure()]
public static void GetCustInfo(SqlString PhoneNo, out SqlString CustInfo)
{
    // code...
}

This is how I try to create the function:

CREATE FUNCTION [dbo].[GetCustInfo] (@PhoneNo nvarchar(50))
RETURNS nvarchar(max) WITH EXECUTE AS CALLER
AS EXTERNAL NAME  CustFromPhone.[ManagedCodeAndSQLServer.BaseFunctionClass].GetCustInfo

and this is the error:

CREATE FUNCTION failed because T-SQL and CLR types for return value do not match.

1
  • your right... look the comment below what my mistake was. Commented May 31, 2011 at 20:33

2 Answers 2

3

even if you ask nicely ... a void function won't return something that can be converted to a nvarchar

Sign up to request clarification or add additional context in comments.

2 Comments

I've read that sql procedure's can't have a return value. (maybe that's only true for vb.net?)
you are mixing up some concepts. to keep things simple: functions return something ... procedures don't. that's when you talk about the theoretic concept of functions or procedures. when it comes to everyday language, many people (including me) tend to call everything a function, or use both terms interchangable. to be precisely, there is no such thing as a void function ... if you have a void foo() that's always a procedure, but usually you don't have to worry about it. in this case it's simple ... your SQL function says it returns a nvarchar(max) ... your GetCustInfo(...) returns nothing
1

Try this maybe:

[SqlProcedure()]
public static SqlString GetCustInfo(SqlString PhoneNo)
{
    // code...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.