C # A syntax error solution near go is prompted during the dynamic storage creation process.

Source: Internet
Author: User

1 public int CreateDB_KillProc_proc ()
2 {
3 int result = 0;
4 string SqlStr = "";
5 // combine SQL statements
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
15 declare @ SQL nvarchar (500)
16 declare @ spid nvarchar (20)
17 declare # tb cursor
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 // execute the SQL statement
28 try
29 {
30 result = DbHelperSQL. ExecuteSql (SqlStr );
31}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.