The document discusses creating store procedures in SQL Server. It explains the syntax for creating store procedures and provides examples of creating a table and inserting sample data. It also shows how to create a store procedure that accepts input and output parameters to return a student name. The document ends with a quiz about creating a database and table for students and performing queries on it using store procedures and other SQL statements.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
20 views9 pages
Basis Data - Pertemuan5
The document discusses creating store procedures in SQL Server. It explains the syntax for creating store procedures and provides examples of creating a table and inserting sample data. It also shows how to create a store procedure that accepts input and output parameters to return a student name. The document ends with a quiz about creating a database and table for students and performing queries on it using store procedures and other SQL statements.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9
Perancangan Basis Data
Pertemuan 5
Hans Saputra, S.kom., MMSI
Alter Table and Add New Field Create Store Procedure in MS SQL Server Di SQL Server, prosedur adalah program tersimpan yang digunakan untuk memasukkan parameter. Store procedure tidak mengembalikan nilai seperti fungsi. Namun, bisa mengembalikan status kesuksesan / kegagalan pada prosedur yang menamakannya. Contoh tag SP ini :
Insert into tbl_Students (Firstname, lastname, Email)
Values('AMIR', ‘AMIR', ‘[email protected]') Create Store Procedure in MS SQL Server Create PROCEDURE GetstudentnameInOutputVariable (
@studentid INT, --Input parameter , Studentid of the student
@studentname VARCHAR(200) OUT -- Out parameter declared with the help of OUT keyword ) AS BEGIN SELECT @studentname= Firstname+' '+Lastname FROM tbl_Students WHERE studentid=@studentid END SQL Query List SELECT column_name(s) LIKE FROM table_name WHERE column_name LIKE pattern SELECT column_name(s) ORDER BY FROM table_name ORDER BY column_name [ASC|DESC] SELECT column_name(s) SELECT FROM table_name TRUNCATE TABLE TRUNCATE TABLE table_name UPDATE table_name UPDATE SET column1=value, column2=value,... WHERE some_column=some_value SELECT column_name(s) WHERE FROM table_name WHERE column_name operator value SQL Query List DELETE FROM table_name WHERE some_column=some_valueor DELETE FROM table_name DELETE (Note: Deletes the entire table!!) DELETE * FROM table_name (Note: Deletes the entire table!!) DROP DATABASE DROP DATABASE database_name DROP TABLE DROP TABLE table_name QUIZ • Buatlah Database Mahasiswa dan buatlah query untuk menjawab case dibawah ini: 1. Tampilkan seluruh isi dari tabel mahasiswa dengan menggunakan store procedure 2. Tampilkan isi table dan diurutkan dari kolom nama 3. Menambahkan isi tabel mahasiswa dengan nama sesuai nim dan nama kalian 4. Perbaharui tabel mahasiswa dimana nim kalian diubah menjadi 100100123 5. Hapus record dari tabel mahasiswa hanya nim 100100123