quản lý từ nút Người sử dụng một cơ sở dữ liệu trong Enterprise Manager. Cả hai có thể quản lý người dùng hiện tại và tạo người dùng mới. Tuy nhiên, khi bạn tạo ra một đăng nhập cho SQL Server, bạn thường chỉ định một mật khẩu xác thực và cơ sở dữ liệu mặc định như: | 665 Appendix B Solutions to the Exercises select AcquisitionType AcquisitionType from AcquisitionType where AcquisitionTypeld @AcquisitionTypeid -- insert everything insert into InventoryDenormalized InventoryId Make Model Location Status LeaseNumber StartDate EndDate FirstName LastName Rent Lease Cost AcquisitionType AcquisitionDate values @InventoryId @Make Model Location Status @LeaseNumber @StartDate EndDate FirstName LastName Rent Lease Cost AcquisitionType AcquisitionDate FETCH NEXT FROM CrsrVar INTO Inventoryid EquipmentId LocationId StatusId LeaseId LeaseScheduleId OwnerId Rent Lease Cost AcquisitionTypeID AcquisitionDate END CLOSE CrsrVar DEALLOCATE CrsrVar select from InventoryDenormalized drop table InventoryDenormalized return 0 666 SQL Server 2000 Stored Procedure Programming CHAPTER 5. FUNCTIONS Exercise Create a Select statement that returns the quarter from the current date in the following format 3Q2000 . Exercise Solution Use the following code Select DATENAME q GETDATE Q DATENAME yyyy GETDATE Exercise Create a table called ExpectedShippingDate that contains the following fields ExpectedShippingDateId offset from the starting date ExpectedShippingDate ExpectedShippingDateOfMonth ExpectedShippingMonth ExpectedShippingYear ExpectedShippingQuarter The table should be filled with one record for each date since 1 1 2000. Create a stored procedure Setup_ExpectedShippingDate to fill it. Exercise Solution Use the following statement to create the table CREATE TABLE dbo . ExpectedShipDate ExpectedShipDateId smallint NOT NULL ExpectedShipDate smalldatetime NULL ExpectedShippingMonth tinyint NULL ExpectedShippingDay tinyint NULL ExpectedShippingYear smallint NULL 667 Appendix B Solutions to the Exercises ExpectedShippingQuarter char 6 NULL ON PRIMARY GO The table can be filled using the following stored procedure CREATE PROCEDURE Setup_ExpectedShipDate @ExpectedShipDate smalldatetime 1 1 2000 @day_number smallint 5000 as declare .