SQL server子查询
exec xp_cmdshell 'md E:\project'
--先判断数据库是否存在如果存在就删除
if exists(select * from sysdatabases where name='bbsDB')
drop database bbsDB
--创建数据库文件
create database bbsDB
--主数据库文件
on primary
(
name='bbsDB_data',--为主要数据库文件命名
filename='E:\project\bbsDB_data.mdf',--主数据库文件的路径
size=10mb--初始大小
)
log on(
--日志文件
name='bbsDB_log',
filename='E:\project\bbsDB_log.ldf',
size=3mb,
maxsize=20mb--最大增长量为
)
go
use bbsDB
drop table BBSUsers
create table BBSUsers(
UID int identity(1,1) primary key not null,--标识列自增长
UName varchar(15) not null,--用户名,昵称
UPassword varchar(16) not null,--密码不能少于6位数默认为(888888)
USex bit not null,--性别1代表男
UEmail varchar(20) null, --电子邮件必须包含@默认值为(P@P.com)
UClass int not null,--用户的等级(1)
UregDate datetime null,--注册日期(注册时系统时间)
Uremark varchar(255) null, --备注信息(备注)
Upoint int not null,--用户的积分,点数(20)
UBirthday datetime null,--用户生日
Ustate int null--状态(0默认为离线)
)
go
select UPassword from BBSUsers
alter table BBSUsers-- 为密码添加检查约束长度大于=6的长度
add constraint CK_upassword check(len(UPassword)>=6)
alter table BBSUsers--为密码添加默认约束(888888)
add constraint DE_upassword default ('888888') for UPassword
alter table BBSUsers--Email检查约束@
add constraint CK_uemail check (UEmail like '%@%')
alter table BBSUsers--为E-mail添加默认约束P@P.com
add constraint DE_uemail default('P@P.co
相关文档:
--------------------------------------------------------------------------
-- Author : 原著:不详 改编:htl258(Tony)
-- Subject: 完善SQL农历转换函数(显示中文格式,加入润月的显示)
-------------------------------------------------------------------------- ......
select * from ((select bill.id billId,bach.riskRate risk,bach.assureRate assure from AcptBillInfo bill,AcptBach bach where bill.acptBatchId=bach.id and bill.rgctId=? )abach left outer join AcptSignMoney sig on abach.billId = sig.billId) ......
问题: 一台服务器上运行了SQL Server,SQL Server Agent,Distributed Transaction,Coordinator这三个服务,请问这台服务器是一台什么样的服务器?这三个服务具体有什么作用?
这是一台数据库服务器.
SQL Server 这是主数据库服务,而且形成了SQL Server的支柱。它用于存储和提取数据。
SQL Server Agent 也叫SQL Server代 ......
inner join(等值连接) 只返回两个表中联结字段相等的行
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
INNER JOIN 语法:
INNER JOIN 连接两个数据表的用法:
SELECT * from 表1 INNER JOIN 表2 ON 表1.字段号=表2 ......