A SQL Server Script Tutorial
SQL Server scripts are used to create stored procedures, which are database objects saved on the server and used to retrieve and insert data on the database tables. SQL Server tables contain your data, and a SQL Server script gives you an interface for retrieving this data. Scripting these stored procedures creates a block of code, and you create these scripts in SQL Server Management Studio included with your database software.
Instructions
-
-
1
Click the Windows "Start" button and select "All Programs." Click "SQL Server" in the menu's program groups and then click "SQL Server Management Studio" to open your database console.
-
2
Click the database on the left side of the window. Click the "New Query" button at the top of the window. This opens a SQL scripting window where you create your stored procedures.
-
-
3
Type your script. The script you type depends on what you want to do with the table data. For instance, if you want to retrieve records from the table, you use the "select" statement. Most database scripts are "select" statements, so you can return data to a desktop or Web application. The following script retrieves all records from a customer table:
select * from customer
-
4
Click the "Execute" button at the top of your SQL Server Management Studio window. This lets you test your script and review the data returned.
-
5
Click the "Save" button. A dialog box opens, prompting you for a script file name. Type a name and click "Save." This saves your script for future use.
-
1