问题是:
用批处理执行SQL语句 报错
批处理如下:
echo off 正在创建数据库....
isql -Usa -Ppassword -S. -i1.sql
pause ..........
isql -Usa -Ppassword -S. -iSQL.sql
pause ..........
结果为:
C:/Documents and Settings/戈平/My Documents/Library>echo off 正在创建数据库....
off 正在创建数据库....
C:/Documents and Settings/戈平/My Documents/Library>isql -Usa -Ppassword -S. -i1
.sql
1> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> Msg 170, Level 15, State 1, S
erver 吴戈平, Line 1
第 1 行: '' 附近有语法错误。
C:/Documents and Settings/平/My Documents/Library>pause ..........
请按任意键继续. . .
C:/Documents and Settings/平/My Documents/Library>isql -Usa -Ppassword -S. -iS
QL.sql
1> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 2
3> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37> 38> 39> 40> 41> 42> 4
3> 44> 45> 46> 47> 48> 49> 50> 51> 52> 53> 54> 55> 56> 57> 58> 59> 60> 61> 62> 6
3> 64> 65> 66> 67> 68> 69> 70> 71> 72> 73> 74> 75> 76> 77> 78> 79> 80> 81> 82> 8
3> 84> 85> 86> 87> 88> 89> 90> 91> 92> 93> 94> 95> 96> 97> 98> 99> 100> 101> 102
> 103> 104> 105> 106> 107> 108> 109> 110> 111> 112> 113> 114> 115> 116> 117> 118
> 119> 120> 121> 122> 123> 124> 125> 126> 127> 128> 129> 130> 131> 132> 133> 134
> 135> 136> 137> 138> 139> 140> 141> 142> 143> 144> 145> 146> 147> 148> 149> 150
> 151> 152> 153> 154> 155> 156> 157> 158> 159> 160> 161> 162> 163> 164> 165> 166
> 167> 168> Msg 170, Level 15, State 1, Server 吴戈平, Line 1
第 1 行: '' 附近有语法错误。
C:/Documents and Settings/平/My Documents/Library>pause ..........
请按任意键继续. . .
文件:1.sql
CREATE DATABASE Library
ON
(NAME =Library_Data,
FILENAME ='C:/Library_Data.MDF',
SIZE = 2,
FILEGROWTH = 10%)
LOG ON
(NAME =Library_Log,
FILENAME ='C:/Library_Log.LDF',
SIZE = 1,
FILEGROWTH = 10%)
GO
文件:SQL.sql
use [Library]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Borrow_view]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[Borrow_view]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Book_del]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Book_del]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Book_ifo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Book_ifo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Borrow_ifo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Borrow_ifo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Pwd_log]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Pwd_log]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Reader_del]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Reader_del]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Reader_ifo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Reader_ifo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Return_ifo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Return_ifo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[结果]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[结果]
GO
CREATE TABLE [dbo].[Book_del] (
[Book_id_del] [varchar] (14) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_name_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_auther_del] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_publish_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_letters_del] [text] COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_count_del] [numeric](2, 0) NOT NULL ,
[Book_publish_time_del] [datetime] NOT NULL ,
[Book_price_del] [float] NOT NULL ,
[Book_type_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_date_del] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Book_ifo] (
[Book_id] [varchar] (14) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_auther] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_publish] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_letters] [text] COLLATE Chinese_PRC_CI_AS NULL ,
[Book_count] [int] NULL ,
[Book_publish_time] [datetime] NULL ,
[Book_price] [float] NULL ,
[Book_type] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Book_Insert_Date] [datetime] NOT NULL ,
[Book_index] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Borrow_ifo] (
[Borrow_reader_id] [varchar] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Borrow_book_id] [varchar] (14) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Borrow_reader_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Borrow_time] [datetime] NULL ,
[Borrow_book_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Borrow_book_price] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Borrow_book_count] [int] NULL ,
[Borrow_count_all] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Pwd_log] (
[Log_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Log_pwd] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Reader_del] (
[Reader_id_del] [varchar] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_sfid_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_name_del] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_sex_del] [varchar] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_spe_del] [varchar] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_type_del] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_max_count_del] [int] NULL ,
[Reader_home_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_phone_del] [varchar] (13) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_money] [float] NULL ,
[Reader_date_del] [datetime] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Reader_ifo] (
[Reader_id] [varchar] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_sfid] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_name] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_sex] [varchar] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_spe] [varchar] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Reader_type] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_max_count] [int] NOT NULL ,
[Reader_home] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_phone] [varchar] (13) COLLATE Chinese_PRC_CI_AS NULL ,
[Reader_money] [float] NULL ,
[Reader_date] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Return_ifo] (
[Return _reader_id] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Return _book_id] [varchar] (14) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Return _reader_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Borrow_time] [datetime] NULL ,
[Return _time] [datetime] NULL ,
[Return _book_name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Return _money] [float] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[结果] (
[Book_id_del] [varchar] (14) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_name_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_auther_del] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_publish_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Book_letters_del] [text] COLLATE Chinese_PRC_CI_AS NULL ,
[Book_count_del] [numeric](2, 0) NULL ,
[Book_publish_time_del] [datetime] NULL ,
[Book_price_del] [money] NULL ,
[Book_type_del] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Book_date_del] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.Borrow_view
AS
SELECT dbo.Borrow_ifo.Borrow_reader_id, dbo.Reader_ifo.Reader_id,
dbo.Book_ifo.Book_id, dbo.Reader_ifo.Reader_name, dbo.Reader_ifo.Reader_money,
dbo.Borrow_ifo.Borrow_book_count, dbo.Book_ifo.Book_name,
dbo.Book_ifo.Book_publish, dbo.Book_ifo.Book_price, dbo.Book_ifo.Book_type,
dbo.Book_ifo.Book_letters
FROM dbo.Borrow_ifo INNER JOIN
dbo.Reader_ifo ON
dbo.Borrow_ifo.Borrow_reader_id = dbo.Reader_ifo.Reader_id INNER JOIN
dbo.Book_ifo ON dbo.Borrow_ifo.Borrow_book_id = dbo.Book_ifo.Book_id
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO