powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / Сертификация и обучение [игнор отключен] [закрыт для гостей] / Testking vs Microsoft
2 сообщений из 2, страница 1 из 1
Testking vs Microsoft
    #32207355
Фотография Magnus23
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Доброго времени суток!
Вопрос к людям сдававшим 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.
The code using the cursor looks complicated but it is the ONLY solutionthat handles NULL values in the Country column in the Customers table. It will skip all NULL rowsin the Customers table.


Если к ответу А добавить :
Код: plaintext
Where Coutry is Not NULL 

то все работает нормально... И никаких курсоров.
Т.е. суть данного вопроса сводится к тому чтобы выбрать из четырех неправильных ответов менее неправильный????


Если я что то упустил, буду благодарен за разьяснение.
...
Рейтинг: 0 / 0
Testking vs Microsoft
    #32238432
Mik Prokoshin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Угу. Кстати МС всегда подчеркивает, что надо найти наиболее ПОДХОДЯЩИЙ ответ... В данном случае, если остальные выборки дают неверные результаты, то естественно, что наиболее подходит неоптимальный по скорости и сложности ответ :-)
P.S. Кстати, я не гуру и экзамен не сдавал, просто IMHO :-)
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Сертификация и обучение [игнор отключен] [закрыт для гостей] / Testking vs Microsoft
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]