Execute SQL statements in the BAT file

Source: Internet
Author: User

 

  I wrote a BAT file to my colleagues a long time ago to generate related objects in the database and database. Today I want to write a BAT file to update the customer's database, but I forgot the syntax. difficult to find. asking people on QQ and sending T on the Forum may be too simple and no one will reply. so I am still the truth of myself: "I can only rely on myself this year ". so I am looking for it, and finally I am not happy with it.1: osql -E-S-I update. SQL (the location of update. SQL is the path of the SQL file to be executed, but it is also another file)Save as BAT file 2: update. SQL is created. It is actually an SQL statement that can be executed in the query analyzer. below is My SQL statement use jycmis

ALTER TABLERduty addIsdayBit ------------ modify the rduty table
Go
Create Table rsalarygrade (
Sgrade_no varchar (4 ),
Sgrade_name varchar (15 ),
Sgrade_money decimal (9, 2) default (0) Check (sgrade_money> = 0)
, Bak varchar (10 ),
T_name varchar (12 ),
T_date datetime default (getdate ())
) ---------- The above is the "increment" table
Go
Alter table rperson
Add Otherpermit_no varchar (25), -- other certificates
 Otherpersmint_name varchar (10), -- Other Certificate Name else
Sion     Varchar (25), -- Industry
Work_experiences  Varchar (200), -- working experience
Beforturnsgrade_no varchar (4), -- pay-as-you-go
Turndate          SmalldatetimeDefault (dateadd (month, 3, getdate ())),
-- Estimate the positive date
Factturndate     Smalldatetime-- Returns the exact positive date,
Turnsgrade_noVarchar (4), -- renew pay-as-you-go and other resources
Introduction   Varchar (12), which refers to telephone calls
Isoutsafe        Char (2) Check (isoutsafe in ('yes', 'no'), -- whether to return warranty
ADDR              Varchar (100) -- residential address
--------------- The preceding table is used to modify the personnel data table.
Create Table rfloor (--Dormitory?
Floor_noVarchar (4),-- Dormitory ???Master?
Floor_nameVarchar (15 ),--Dormitory? Name?
BakVarchar (10),--? Note
T_nameVarchar (12), -- Operator
T_dateDatetimeDefault (getdate ()),
Constraint pk_floor_no primary key (floor_no) -- operation ??

Go

Create Table rdormtype (-- Dormitory? Type
Dtype_noVarchar (4 ),--? Type ??Master?
Dtype_name varchar (15 ),--? Type name?
BakVarchar (10),--? Note
T_nameVarchar (12), -- Operator
T_dateDatetime  Default (getdate (), -- operation ??Default (getdate ())
Constraint pk_dtype_no primary key (dtype_no ))
Go

Create Table roomtype (--Room Type
Rmtype_noVarchar (4 ),-- Room type ??Master?
Rtype_nameVarchar (15 ),-- Room name?
BakVarchar (10),--? Note
T_nameVarchar (12), -- Operator
T_dateDatetimeDefault (getdate () -- operation ??
, Constraint pk_rmtype_no primary key (rmtype_no)
)
Go

Create Table room-- Room?
(Room_noVarchar (4 ),--Room ???Master?
 Room_nameVarchar (15 ),--Room? Name?
 Dtype_noVarchar (4),--? Type ???? Dormitory? Type table
 Rmtype_noVarchar (4 ),--Room Type ???? Source room type table
 FullcountInt, -- Resident?
 IncountIntCheck (incount> = 0) default (0), -- resident?
 Outmoney Decimal (5, 1) default (0 ),--Fee deduction
 BakVarchar (10 ),--? Note
 T_nameVarchar (12 ),--Operator
 T_dateDatetimeDefault (getdate (), -- operation ??
Constraint pk_room_noPrimary KeyNonclustered (room_no ),
Constraint fk_dtype_no foreign key (dtype_no) ReferencesRdormtype (dtype_no) On Delete no action on update cascade,
Constraint fk_rmtype_no foreign key (rmtype_no) References roomtype (rmtype_no) on Delete no action on update Cascade
)
Go
Create Table bed (--Bed
Bed_noVarchar (4 ),--Bed ??Master? (Yes? Cheng? Bit)
Room_noVarchar (4 ),--Room ???Master? ?? Source room? Table
IsfullChar (2)Check (isfull in ('yes', 'no') default ('no'), -- whether it is a residentCheckisfullin 'Yes ', 'no' default 'no'
BakVarchar (10 ),--? Note
T_nameVarchar (12 ),--Operator
T_dateDatetimeDefault (getdate ()),--Operation ??
Constraint pk_roomandbedno primary keyNonclustered (bed_no, room_no ),
Constraint fk_room_no foreign key (room_no) References room (room_no) on Delete no action on update Cascade
)
Go
Create Table rquarter(
P_noVarchar (10), -- Job?Master
P_naVarchar (12), -- Name
Room_noVarchar4), -- Dormitory ??
Bed_noVarchar (4), -- Bed ??Main, external ?? Yu bed
Moveindate Smalldatetime ,--Check in ??Master
ClothsendChar (2)Check (clothsend in ('no', 'yes') default ('no'), -- is it true? Placement ServerCheck in?
SenddateSmalldatetime null,-- Work server? Put ??
SaloutChar (2)Check (salout in ('yes', 'no') default ('no '),
SaldateSmalldatetime null, -- deduction date
IsstudyChar (2)Check (isstudy in ('yes', 'no') default ('no '),
LivethingChar (2)Check (livethingIn ('yes', 'no') default ('no'), -- is it true? Home necessities
IsoutChar (2)Check (isout in ('yes', 'no') default ('no '),
OutdateSmalldatetime null, -- Expiry date
OutreasonVarchar (100 ),--Reason
BakVarchar (10 ),--? Note
T_nameVarchar (12 ),-- Operator
T_dateDatetime-- Operation ??
Constraint pk_pomobeindate primary key (
)

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.