标题:如何执行SQL生成的语句
取消只看楼主
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
结帖率:100%
 问题点数:0 回复次数:3 
如何执行SQL生成的语句
以下是用SQL直接生成的语句:如何用C#执行???

USE [master]
GO
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'mobile')
BEGIN
CREATE DATABASE [mobile] ON  PRIMARY
( NAME = N'mobile', FILENAME = N'E:\VS2005(C#)PC短信群发软件源代码\c_sms\SMS\SMS\DataBase\mobile.mdf' , SIZE = 6144KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON
( NAME = N'mobile_log', FILENAME = N'E:\VS2005(C#)PC短信群发软件源代码\c_sms\SMS\SMS\DataBase\mobile_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
END

GO
EXEC dbo.sp_dbcmptlevel @dbname=N'mobile', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [mobile].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [mobile] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [mobile] SET ANSI_NULLS OFF
GO
ALTER DATABASE [mobile] SET ANSI_PADDING OFF
GO
ALTER DATABASE [mobile] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [mobile] SET ARITHABORT OFF
GO
ALTER DATABASE [mobile] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [mobile] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [mobile] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [mobile] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [mobile] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [mobile] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [mobile] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [mobile] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [mobile] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [mobile] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [mobile] SET  ENABLE_BROKER
GO
ALTER DATABASE [mobile] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [mobile] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [mobile] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [mobile] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [mobile] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [mobile] SET  READ_WRITE
GO
ALTER DATABASE [mobile] SET RECOVERY FULL
GO
ALTER DATABASE [mobile] SET  MULTI_USER
GO
ALTER DATABASE [mobile] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [mobile] SET DB_CHAINING OFF
USE [mobile]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_telsend]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_telsend](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [telnum] [varchar](50) NULL,
    [telcontent] [varchar](max) NULL,
    [teltime] [varchar](50) NULL,
 CONSTRAINT [PK_tb_telsend] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_tel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_tel](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [username] [varchar](50) NULL,
    [usersex] [varchar](10) NULL,
    [usertel] [varchar](50) NULL,
 CONSTRAINT [PK_tb_tel] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[worker]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[worker](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [jh] [varchar](50) NULL,
    [shfzh] [varchar](50) NULL,
    [danwei] [varchar](50) NULL,
    [xm] [varchar](50) NULL,
    [sex] [varchar](2) NULL,
    [address] [varchar](200) NULL,
    [phone] [varchar](50) NULL,
    [dnt] [datetime] NULL,
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[times]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[times](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [lx] [varchar](50) NULL,
    [days] [varchar](50) NULL,
    [times] [varchar](50) NULL,
 CONSTRAINT [PK_times] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_admin]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_admin](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [adminusername] [varchar](50) NULL,
    [adminuserpwd] [varchar](50) NULL,
    [power] [nchar](1) NULL,
 CONSTRAINT [PK_tb_admin] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_note]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_note](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [type] [varchar](50) NULL,
    [note] [varchar](max) NULL,
 CONSTRAINT [PK_tb_note] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resvice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resvice](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [smsnum] [varchar](50) NULL,
    [smscontent] [varchar](max) NULL,
 CONSTRAINT [PK_tb_resvice] PRIMARY KEY CLUSTERED
(
    [id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
搜索更多相关主题的帖子: SQL 语句 
2010-09-02 10:01
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
回复 2楼 playermaker
在C#程序中

http://www.
2010-09-02 15:47
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
???

http://www.
2010-09-03 16:55
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
得分:0 
我试过了,还是不能同时都执行,只能先执行创建数据库,再执行创建表!!还是要谢谢大家

http://www.
2010-09-06 17:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-317478-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.394628 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved