c#动态创建存储过程中,提示go 附近有语法错误解决方案
2010-09-30 22:45:55 来源:WEB开发网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 }
32 catch (Exception e)
33 {
34 ErrStr = e.Message;
35 return -2;
36 }
37 return result;
38 }
更多精彩
赞助商链接