Minggu, 15 Februari 2009

Microsoft SharePoint Team Blog
The official blog of the Microsoft SharePoint Product Group

Creating a Table With SQL


Introduction



In SQL, to create a table, you start with the following statement:

CREATE TABLE TableName;
The CREATE TABLE expression is required. The TableName factor specifies the name of the new table. The TableName can use the rules and suggestions we reviewed for the tables.

After specifying the name of the table, you must create at least one category, called a column of data.

Using Sample Code



To assist you with creating a table, Microsoft SQL Server can generate sample code for you. You can then simply modify or customize it. First display or open an empty query window. To display the Templates Explorer, on the main menu, you can click View -> Templates Explorer. In the Templates Explorer, expand the Table node. Under table, drag Create Table and drop it in the query window. Sample code would be generated for you.

Tables Maintenance


Introduction



Table maintenance consists of reviewing or changing its aspects. This includes reviewing the list of tables of a database, renaming a table, or deleting it.

Viewing the Properties of a Table



Like every other object of a database or of the computer, a table possesses some characteristics that are proper to it. To view these characteristics, in the Object Explorer, right-click the table and click Properties.

Opening a Table



Most operations require that you open a table before using it. There are various ways a table displays, depending on how you want to examine it:

To view the structure of a table, perhaps to change its columns, in the Object Explorer, expand your database and its Tables node. Right-click the table and click Modify. The table would open in design view, the same view you use to visually create a table.
If you want to view the SQL code of a table, in the Object Explorer, right-click the table, position the mouse on Script Table AS, CREATE To, and click New Query Editor Window
To open a table to view its data, perhaps to perform data entry, in the Object Explorer, right-click the table and click Open Table
Tables Review



To see the list of tables of a database in the Object Explorer, you can click the Tables node:


To see the list of tables of a database using SQL, in a Query window, specify the database (using a USE statement), and execute sp_help (it is a stored procedure). Here is an example:




source : http://blogs.msdn.com/sharepoint/default.aspx