|
Testking vs Microsoft
|
|||
---|---|---|---|
#18+
Доброго времени суток! Вопрос к людям сдававшим 229 и просто гуру. помогите разобраься с данной проблемой. Вопрос взят из Тесткинга 41. (41) You are a database developer for Litware,Inc. You are restructuring the company's sales database. The database contains customer information in a table named customers. This table includes a character field named country that contains the name of the country in which the customer is located. You have created a new table named country. The scripts that were used to create the customers and country tables are shown below: CREATE TABLE dbo.Country ( CountryID int IDENTITY(1,1) NOT NULL, CountryName char(20) NOT NULL, CONSTRAINT PK_Country PRIMARY KEY CLUSTERED (CountryID) ) CREATE TABLE dbo.Customers ( CustomerID int NOT NULL, CustomerName char(30) NOT NULL, Country char(20) NULL, CONSTRAINT PK_Customers PRIMARY KEY CLUSTERED (CustomersID) ) You must move the country information from the customers table into the new country tables as quickly as possible. Which script should you use? A. INSERT INTO Country (CountryName) SELECT DISTINCT Country FROM Customers B. SELECT (*) AS ColID, cl.Country INTO Country FROM(SELECT DISTINCT Country FROM Customers)AS c1, (SELECT DISTINCT Country FROM Customers) AS c1, WHERE c1.Country >=c2.Country GROUP BY c1.Country ORDER BY 1 C. DECLARE @Country char (20) DECLARE cursor_country CURSOR FOR SELECT Country FROM Customers OPEN cursor_country FETCH NEXT FROM cursor_country INTO @Country WHERE (@@FETCH_STATUS <> -1) BEGIN If NOT EXISTS ( SELECT countryID FROM Country WHERE CountryName = @Country) INSERT INTO Country (CountryName) VALUES (@Country) FETCH NEXT FROM cursor_country INTO @Country END D. DECLARE @SQL varchar (225) SELECT @SQL = 'bcp "SELECT ColID = COUNT(*), c1. Country' + 'FROM (SELECT DISTINCT Country FROM Sales..Customers) AS cl,'+ WHERE c1.Country >= c2.Country' + 'GROUP BY c1.Country ORDER BY 1" ' + 'query out c:\country.txt -c' EXEC master..xp_cmdshell @SQL, no_output EXEC master..xp_cmdshell 'bcp Sales..country in c:\country. Txt-c', no_output Answer: C Как видим верным ответом тесткинг считает С... Это что, больная фантазия разработчиков экзамена? Ошибка? Или издевательство? Особенно смущает обьяснение в тесткинге: Код: plaintext 1.
Если к ответу А добавить : Код: plaintext
то все работает нормально... И никаких курсоров. Т.е. суть данного вопроса сводится к тому чтобы выбрать из четырех неправильных ответов менее неправильный???? Если я что то упустил, буду благодарен за разьяснение. ... |
|||
:
Нравится:
Не нравится:
|
|||
14.07.2003, 15:56 |
|
Testking vs Microsoft
|
|||
---|---|---|---|
#18+
Угу. Кстати МС всегда подчеркивает, что надо найти наиболее ПОДХОДЯЩИЙ ответ... В данном случае, если остальные выборки дают неверные результаты, то естественно, что наиболее подходит неоптимальный по скорости и сложности ответ :-) P.S. Кстати, я не гуру и экзамен не сдавал, просто IMHO :-) ... |
|||
:
Нравится:
Не нравится:
|
|||
17.08.2003, 16:30 |
|
|
start [/forum/topic.php?fid=34&msg=32207355&tid=1552060]: |
0ms |
get settings: |
12ms |
get forum list: |
15ms |
check forum access: |
5ms |
check topic access: |
5ms |
track hit: |
150ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
50ms |
get tp. blocked users: |
2ms |
others: | 17ms |
total: | 271ms |
0 / 0 |