请大家帮我看看这个自定义函数怎么改?在线急等!!!
CREATE FUNCTION fnGetClientPurchaseOrderData
(
@FromDbName varchar(50)
)
RETURNS table
AS
RETURN
(
exec( 'SELECT '+@FromDbName+ '.dbo.purchaseorder.*, ISNULL( '+@FromDbName+ '.dbo.purchaseorderContrast.ModifyDate,
'+@FromDbName+ '.dbo.purchaseorder.InputDate) AS ModifyDate
FROM '+@FromDbName+ '.dbo.purchaseorder a LEFT OUTER JOIN
'+@FromDbName+ '.dbo.purchaseorderContrast b ON
a.PurchaseOrderID = b.PurchaseOrderID ')
) -- 14行
这样写报错14行 ') '附近有语法错误,请问怎么改???
------解决方案--------------------函数内是不能执行动态sql的,改造成存储过程实现吧.