TAILIEUCHUNG - Create a New Table with Data from Existing Tables

6,7 tạo một bàn mới với dữ liệu từ hiện tại Bàn tôi thường cần để tạo bảng mới từ dữ liệu hiện có. Nếu bảng đã tồn tại, tôi cần phải xóa bảng cũ đầu tiên. | Create a New Table with Data from Existing Tables I often need to create new tables from existing data. If the table already exists I need to delete the old table first. How do I do this using T-SQL Technique To perform these tasks you will create two T-SQL statements and use them in one Command object. Here are the two statements that will be used IF EXISTS SELECT FROM sysobjects WHERE id object_id N Northwind . dbo . MyProdAndCat DROP TABLE Northwind . dbo . MyProdAndCat SELECT INTO MyProdAndCat FROM Categories INNER JOIN ProductsON The first statement checks for the existence of the particular table you will be creating in this case MyProdAndCat. This statement demonstrates a couple of techniques that you can use in T-SQL Using the EXIST statement with a SELECT statement querying the system table called sysobjects Using an IF statement to conditionally execute another command in this case the DROP TABLE statement Tip Now that you have learned this technique you will want to use it repeatedly. Make sure you mark this page The last statement uses an inner join to join two tables displaying the CategoryName and ProductName. The clause that creates the new table is this INTO MyProdAndCat This tells SQL Server to create a new table called MyProdAndCat from the SELECT statement that is specified. Steps Open and run the Visual Basic .NET-Chapter 6 solution. From the main form click on the button with the caption How-To . You will see the SQL string specified in the Technique section displayed in a label. If you click the Execute button the new table is generated a SELECT statement is executed and the results are displayed in the DataGrid object see Figure . 1. Create a Windows Form. Then place the controls listed in Table with the following properties set as displayed in Figure . Table . Control Property Settings for This How-To Object Property Setting Label Text

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.