当前位置:编程学习 > C#/ASP.NET >>

c#动态创建存储过程中,提示go 附近有语法错误解决方案

1  public int CreateDB_KillProc_proc()
 2         {
 3             int result = 0;
 4             string SqlStr = "";
 5             //组合Sql语句
 6             SqlStr += @"USE [RadarDataBase]
 7                     GO
 8                     SET ANSI_NULLS ON
 9                     GO
10                     SET QUOTED_IDENTIFIER ON
11                     GO
12                     create proc [dbo].[P_KillConnections] 
13                     @dbname varchar(200) 
14                     as
15                     declare @sql nvarchar(500) 
16                     declare @spid nvarchar(20) 
17                     declare #tb cursor for 
18                     select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) 
19                     open #tb 
20                     fetch next from #tb into @spid 
21                     while @@fetch_status=0 
22                     begin
23                     exec(kill +@spid) 
24                     fetch next from #tb into @spid 
25                     end close #tb deallocate #tb ";
26                    
27             //执行Sql语句
28             try
29             {
30                 result = DbHelperSQL.ExecuteSql(SqlStr);
31             }

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,