是否可以使用 cfstoredproc创建存储过程?当我运行以下命令时,我在 'GO' 附近得到 Incorrect syntax。
<cffile action="read" file="mypath/myFile.sql" variable="sp_1">
<cfstoredproc procedure="sp_executesql" dataSource="#getDatasource()#">
<cfprocparam type="in" cfsqltype = "cf_sql_varchar" value ='#sp_1#'>
</cfstoredproc>
我的文件.sql
IF OBJECT_ID('getMyData', 'P') IS NOT NULL
DROP PROC getMyData
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE getMyData
@some_var AS NVARCHAR(200)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sql AS NVARCHAR(MAX)
SET @sql = N'SELECT * FROM myTable where id = ''' + @some_var + ''' '
EXEC sp_executeSQL @sql
END
<cfquery name="createGetMyData" dataSource="#getDatasource()#">
#preservesinglequotes(sp_1)#
</cfquery>