数据库上机试验报告1


数据库上机试验报告1
练习一
SQL语句语法
sp_configure [ [ @configname = ] 'option_name'
    [ , [ @configvalue = ] 'value' ] ]
sp_configure 可以显示或更改服务器级别的设置。更改数据库级别设置使用 ALTER DATABASE。更改仅影响当前用户会话的设置使用 SET 语句。
管理员运行RECONFIGURE RECONFIGURE WITH OVERRIDE 更新配置值。
show advanced options 选项用来显示 sp_configure 系统存储过程高级选项。当 show advanced options 设置为 1 时,可以使用 sp_configure 列出高级选项。默认值为 0
two digit year cutoff 选项为了将 2 位数字的年份解释为 4 位数字的年份,从 1753 9999 之间选出一个整数来表示世纪截止年份。
一个比截止年份的后两位数字小或者与其相等的两位数年份与该截止年份处于同一个世纪。而一个比截止年份的后两位数字大的两位数年份所处的世纪比与该截止年份所处的世纪要早。比如,如果 two digit year cutoff 2049(默认值),那么两位数年份 49 被解释为 2049 年,而两位数年份 50 被解释为 1950

该设置将立即生效,无需重新启动服务器。
查看设置生效方法
通过右击数据库服务器,查看属性
运行下面两个SQL语句
EXEC sys.sp_configure 'show advanced options'
EXEC sys.sp_configure 'two digit year cutoff'

事务
BEGIN TRANSACTION
UPDATE account SET money = money - 100
where Name = 'zhangsan'
update account set money = money + 100
where Name = 'lisi'
declare @m int
select @m = money from account where Name = 'zhangsan'
if(@m > 100)
commit
else
rollback


select Name,money,
case
when money>1000 then 'VIP'
when money<1000 then 'Custom'
else N'No money'
end as type
from account



3.
declare @dt datetime = getdate()
declare @date datetime = CONVERT(char(5),@dt,120) + '10-1'
print @date
select DATEPART(WEEKDAY,@date-1)

Related Articles

0 评论 :

发表评论

Quote Of The Day