请纠正我下面给出的功能 [英] Please Correct The Function Which I Given Below
本文介绍了请纠正我下面给出的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建函数cyl_receipt_details_func
(
@cylinder_no_get int
)
AS
RETURN
SELECT
cylinder_no, supplier_name,gas_type,receipt_date,dc_no,dc_date,receipt_qty,uom,
flag,tran_stat,receipt_tran_date,receipt_modified_date
FROM tbl_cyl_gas_main
WHERE cylinder_no = @ cylinder_no_get
它显示错误:关键字'AS'附近的语法不正确
解决方案
纠正它:
CREATE FUNCTION cyl_receipt_details_func( @ cylinder_no_get int )
RETURNS 表
AS
返回
(
SELECT
cylinder_no,supplier_name,gas_type,r eceipt_date,dc_no,dc_date,receipt_qty,uom,
flag,tran_stat,receipt_tran_date,receipt_modified_date
FROM tbl_cyl_gas_main
WHERE cylinder_no = @ cylinder_no_get
)
GO
查看创建功能 [ ^ ]语法。
它应如下所示:
CREATE 功能 cyl_receipt_details_func( @ cylinder_no_get INT )
RETURNS TABLE
AS
< span class =code-keyword> RETURN
SELECT cylinder_no,
supplier_name,
gas_type,
receipt_date,
dc_no,
dc_date,
receipt_qty,
uom,
flag,
tran_stat,
receipt_tran_date,
receipt_modified_date
FROM tbl_cyl_gas_main
WHERE cylinder_no = @cylinder_no_get ;
因为它是一个表值函数,你必须像这样使用它:
SELECT * FROM cyl_receipt_details_func( @ cylinder_no_get 跨度>);
create function cyl_receipt_details_func ( @cylinder_no_get int ) AS RETURN SELECT cylinder_no,supplier_name,gas_type,receipt_date,dc_no,dc_date ,receipt_qty ,uom , flag ,tran_stat ,receipt_tran_date ,receipt_modified_date FROM tbl_cyl_gas_main WHERE cylinder_no=@cylinder_no_get
it shows error :Incorrect syntax near the keyword 'AS'
解决方案
Correct it:
CREATE FUNCTION cyl_receipt_details_func (@cylinder_no_get int) RETURNS TABLE AS RETURN ( SELECT cylinder_no,supplier_name,gas_type,receipt_date,dc_no,dc_date ,receipt_qty ,uom , flag ,tran_stat ,receipt_tran_date ,receipt_modified_date FROM tbl_cyl_gas_main WHERE cylinder_no=@cylinder_no_get ) GO
Check out CREATE FUNCTION[^] syntax.
Hi,
It should look like this:
CREATE FUNCTION cyl_receipt_details_func (@cylinder_no_get INT) RETURNS TABLE AS RETURN SELECT cylinder_no, supplier_name, gas_type, receipt_date, dc_no, dc_date, receipt_qty, uom, flag, tran_stat, receipt_tran_date, receipt_modified_date FROM tbl_cyl_gas_main WHERE cylinder_no = @cylinder_no_get;
Because it is a table-valued function, you have to use it like this:
SELECT * FROM cyl_receipt_details_func(@cylinder_no_get);
这篇关于请纠正我下面给出的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文