首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
You are the administrator of a SQL Server 2000 computer. The server contains a database named Inventory. Users report that sever
You are the administrator of a SQL Server 2000 computer. The server contains a database named Inventory. Users report that sever
admin
2009-05-19
45
问题
You are the administrator of a SQL Server 2000 computer. The server contains a database named Inventory. Users report that several storage locations in the UnitsStored field contain negative numbers. You examine the database’s table structure. The table properties are configured as shown in the exhibit.
You correct all the negative numbers in the table. You must prevent the database from storing negative numbers. You also want to minimize use of server resources and physical I/O.
Which transact-SQL statement should you execute?
选项
A、ALTER TABLE dbo.storagelocations ADD CONSTRAINTS
CK_storagelocations_UnitsStored
CHECK (UnitsStored>= 0)
B、CREATE TRIGGER CK_UnitsStored On StorageLocations
FOR INSERT, UPDATE AS
IF INSERTED, UnitsStored < 0 ROLLBACK TRAN
C、CREATE TABLE ck_unitsstored As @Units >= 0
GO
Sp_bindrule ‘OK_UnitsStored’,
‘StorageLocations, UnitsStored’
GO
D、CREATE PROC UpdateUnitsStored
(StorageLocationID int, @UnitsStored bigint)AS
IF @UnitsStored < 0
DATSERROR (50099, 17)
ELSE
UPDATE storaheLocations
SET UnitsStored = @UnitsStored
WHERE StorageLocationID = @storageLocationID
答案
A
解析
Explanation: CHECK constraints are used to enforce domain integrity by restricting the values that are accepted by a column. They determine which values are valid by testing a logical expression that is not based on data in another column. The problem posed by this scenario can be solved through the implementation of such a constraint. In this solution the CHECK constraint is added in line 1 and the CHECK expression is specified in line 3. The expression specifies that the values contained in the UnitsStored column must be more than or equal to 0.
Incorrect Answers:
B: This solution uses a trigger to perform the CHECK constraint, which a trigger can do. However, it is recommended that triggers only be used when the CHECK constraint cannot meet the functionality required by the application. This is thus not the best answer.
C: In this solution creates a new table is created with the CREATE TABLE statement. This is inappropriate to the problem, as it does not address the insertion of negative values in the existing table.
D: This solution creates a stored procedure to perform the CHECK constraint.
转载请注明原文地址:https://kaotiyun.com/show/uuhZ777K
本试题收录于:
微软70228题库微软认证分类
0
微软70228
微软认证
相关试题推荐
Severaltypesoffinancialriskareencounteredininternationalmarketing;themajorproblemsincludecommercial,political,an
[A]"Ijustdon’tknowhowtomotivatethemtodoabetterjob.We’reinabudgetcrunchandIhaveabsolutelynofinancialrewa
EricHansenwritesabouttravelasaparticipatingenthusiastratherthanamereobserver.【T1】Itgivesthesenineessays,based
In2016,manyshoppersoptedtoavoidthefreneticcrowdsanddotheirholidayshoppingfromthecomfortoftheircomputer.But
Herearesomemanagementtoolsthatcanbeusedtohelpyouleadapurposefullife.1.UseYourResourcesWisely.Yourdecisi
LastThursday,theFrenchSenatepassedadigitalservicestax,whichwouldimposeanentirelynewtaxonlargemultinationalst
DrRichardBergland,abrainresearcherattheHarvardMedicalSchool,haswrittenapapersuggestingthathumanbrainisbasica
Adealisadeal—except,apparently,whenEntergyisinvolved.Thecompany,amajorenergysupplierinNewEngland,provokedjus
随机试题
一束自然光从空气投射到玻璃板表面上,当折射角为30°时,反射光为完全偏振光,则此玻璃的折射率为()。
【2013专业案例真题下午卷】某企业所在地区海拔高度为2300m,总变电所设有110/35kV变压器,从电网用架空线引来一路110kV电源,110kV和35kV配电设备均为户外敞开式;其中,110kV系统为中性点直接接地系统,35kV和10kV系统为中性
根据国家有关规定,大中型公用事业工程必须实行工程监理。下列工程,属于大中型公用事业工程的有()。
首次公开发行股票,在招股说明书中,发行人应披露的股本情况主要包括( )等。
甲和乙围殴丙,将丙打成轻微伤。某县公安局对甲、乙二人作出拘留15日的行政处罚决定,甲认为丙同样对自己实施了暴力行为却没有受到任何处罚,十分不甘。所以甲决定申请行政复议,根据《行政复议法》及其相关规定,下列说法正确的是()。
格什温是20世纪最富有美国特色的一位作曲家,他将美国爵士乐的音乐素材与古典作曲技法熔于一炉,代表作品()以爵士乐为特点,为爵士乐走向世界舞台起了积极作用。
人民法院对非诉行政案件的审查标准是()。
李克强总理说“行大道、民为本、利天下”,谈谈你对“民为本”的看法。
大学生价值观教育的深入开展,除了需要相应的途径、行之有效的方法和策略外,还需要有大学精神的保障。大学精神是大学的灵魂与精髓所在,大学生价值观教育若得不到大学精冲的支撑,无疑会变成无源之水、无本之木。本段文字的主旨是()。
Readthetextbelowabouthowtoorderproducts.Inmostofthelines41—52thereisoneextraword.Itiseithergrammatically
最新回复
(
0
)