1. Trang chủ
  2. » Công Nghệ Thông Tin

SQL Server 2000 Exercise

3 734 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 3
Dung lượng 34,5 KB

Nội dung

SQL Server 2000 Exercise

Tungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10SQL Server 2000Exercise 2: Manipulate Data and Stored Procedure-----Week 5-----Please follow those steps to practise:1. Use bcp to export all data from Orders table of PracticeDB to c:\Orders.txt (or to c:\Orders.csv)2. Change some data in the c:\Orders.txt and save. Then import to Orders table from the text file using bcp3. Import Orders.txt to Orders table using BULK INSERT 4. Create a Linked Server ‘LinkedPracticeDB’ which link to an Access database ‘PracticeDB.mdb’ (firstly you have to create an Access database similar to PracticeDB in SQL Server and input some data). Then do a select data using four-part name and OPENQUERY5. Using ad hoc computer name with OPENROWSET and OPENDATASOURCE functions to select data from ‘PracticeDB.mdb’ 6. Create the following CursorDECLARE @au_lname varchar(40), @au_fname varchar(20)DECLARE Employee_Cursor CURSOR FOR SELECT LastName, FirstName FROM Northwind.dbo.Employees OPEN Employee_Cursor FETCH NEXT FROM Employee_Cursor INTO @au_lname, @au_fname WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'Author:' + @au_fname + ' ' + @au_lnameFETCH NEXT FROM Employee_Cursor INTO @au_lname, @au_fnameEND CLOSE Employee_Cursor DEALLOCATE Employee_Cursor 7. Create the following stored procedure and try to execute with some valuesCREATE PROCEDURE AddNewOrder @OrderID smallint,@ProductName varchar(50),@CustomerName varchar(50),@Result smallint=1 OutputTungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10 Tungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10ASDECLARE @CustomerID smallintBEGIN TRANSACTIONIf not Exists(SELECT CustomerID FROM Customers WHERE [Name]=@CustomerName)BEGINSET @CustomerID= (SELECT Max(CustomerID) FROM Customers)SET @CustomerID=@CustomerID+1INSERT INTO Customers VALUES(@CustomerID,@CustomerName)If Exists(SELECT OrderID FROM [Orders] WHERE OrderID=@OrderID)BEGINSELECT @Result=1ROLLBACK TRANSACTIONENDElseBEGININSERT INTO [Orders](OrderID,ProductName,CustomerID) VALUES(@OrderID,@ProductName,@CustomerID)SELECT @Result=0COMMIT TRANSACTIONENDEND ElseBEGINIf Exists(SELECT OrderID FROM [Orders] WHERE OrderID=@OrderID)BEGINSELECT @Result=1ROLLBACK TRANSACTIONENDElseBEGININSERT INTO [Orders](OrderID,ProductName,CustomerID) VALUES(@OrderID,@ProductName,@CustomerID)SELECT @Result=0COMMIT TRANSACTIONENDENDPrint @ResultTungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10 Tungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10Return9. Using VB 6 or VB.NET to execute the ‘AddNewOrder’ stored procedure 10. Using xp_cmdshell extended stored procedure to send a message (xp_cmdshell ‘net send Hello’)Tungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q10 . Tungvn40@yahoo.com Cong Minh CDROM 70 NCT F2 Q1 0SQL Server 200 0Exercise 2: Manipulate Data and Stored Procedure-----Week 5-----Please. Linked Server ‘LinkedPracticeDB’ which link to an Access database ‘PracticeDB.mdb’ (firstly you have to create an Access database similar to PracticeDB in SQL

Ngày đăng: 01/09/2012, 10:25

TỪ KHÓA LIÊN QUAN

w