December 22, 2016 at 7:05 am
Hello ,
How to Parameters String joın '+@FRM +'
CREATE FUNCTION FN_ORFLİNE
(
@FRM NVARCHAR(3) , @DNM NVARCHAR(3)
)
RETURNS TABLE
AS
RETURN
SELECT ORF.ORDFICHEREF ,
ITM.NAME AS MALZEMEADI ,
ORF.DATE_ AS TARİH ,
ORF.AMOUNT AS MİKTAR ,
ORF.PRICE AS BİRİMFİYAT ,
ORF.TOTAL AS TOPLAMTUTAR
FROM dbo.LG_+@FRM+_+@DNM+_ORFLINE AS ORF
INNER JOIN dbo.LG_+@FRM+_ITEMS AS ITM ON ITM.LOGICALREF = ORF.STOCKREF
December 22, 2016 at 7:29 am
You can't build a table name from variables. You'd need to use dynamic SQL, which I don't think you can use in a function, so you'd need to change it to a stored procedure. Be very careful about SQL injection. Also, if you have the option to change the database design, consider doing so. Passing in object names as parameters smells of an unnormalised database, and if that's what you have, you're likely to experience all sorts of other problems as well.
John
December 22, 2016 at 7:34 am
This are LOGO price and order tables 🙂
You can t return table in this function with parameter. You can insert a temptable with dynamic sql then you can return this table.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply