How to Create a List of Field Names in T-SQL
Microsoft Transact-SQL (T-SQL) provides you with an interface to create tables and table fields using a command line utility included with SQL Server Management Studio. The field names you create in a table define the containers for record data. For instance, a "customer" table contains the fields "first name" and "last name." Each time a record is inserted, the fields hold the individual customer's name.
Instructions
-
-
1
Click the Windows "Start" button and select "All Programs." Click "Microsoft SQL Server," then click "SQL Server Management Studio" to open the database software.
-
2
Click the "New Query" button to open the editor. Type "create table mytable()" (without quotes) to set up the table creation. This command creates the table "mytable." The list of field names is added within the parenthesis.
-
-
3
Add the list of fields to the table. The following adds "name" and "address" fields to the table:
create table mytable (
name varchar(50),
address varchar(100)
)
-
4
Press F5 to execute the command. The table is created along with the list of fields. To check that the creation was successful, type "select * from mytable" and press F5 to see the table results.
-
1