SQL Server

Posted: 19/01/2009 in Komputer
Tag:

Introduction to Microsoft SQL Server 2000

Microsoft SQL Server 2000 is a full-featured relational database management system (RDBMS) that offers a variety of administrative tools to ease the burdens of database development, maintenance and administration. In this article, we’ll cover six of the more frequently used tools: Enterprise Manager, Query Analyzer, SQL Profiler, Service Manager, Data Transformation Services and Books Online. Let’s take a brief look at each:
Enterprise Manager is the main administrative console for SQL Server installations. It provides you with a graphical “birds-eye” view of all of the SQL Server installations on your network. You can perform high-level administrative functions that affect one or more servers, schedule common maintenance tasks or create and modify the structure of individual databases.
Locking down Microsoft SQL Server
Guest Contributor | Jul 18, 2002

Guests: Become a Builder.com member to access all of our articles, newsletters, and community forums.
Members: Login here
By Jonathan Lurie and Timothy Stockstill

Rewriting applications because of database security gaps is costly and time consuming. One of the easiest ways to avoid rewrites is to make security a priority during the initial database design and to enforce security at each tier.

We’ll discuss some of the techniques for providing a solid security foundation for the data tier of an application that resides on Microsoft SQL Server 7 and 2000. While this is a broad topic, we’ll focus on basic security concepts as well as column- and row-level security.

Basic SQL Server security concepts
The security implementations in this article will rely on the basic internal security system provided by SQL Server. Before a user can be granted any level of permissions, a user account must be created on the SQL Server. The user account can be either a domain or local account (using sp_grantlogin), or if the server is operating in the Mixed Security Mode, it can be a built-in SQL Server login (using sp_addlogin). Once a login has been created on the server, the login must then be added as a valid user for any of the databases the user intends to access (using sp_grantdbaccess).

Now that the user has the ability to connect to the server (a login was created) and use one or more databases on the server (a user account was created for each database), the next step is to specify the level of access the user has inside each database. This is done with the GRANT, DENY, and REVOKE SQL DDL statements. The SQL GRANT statement is fairly well understood, so we won’t dive into it here, but the DENY and REVOKE statements are less well known, especially for new database developers, so we’ll focus on them.

The DENY statement
The DENY statement is the opposite of the GRANT statement. Granting a database user access to a table (or object) specifies that the user has the specific right to access the table. Denying a database user access to a table (or object) specifies that under no circumstances should the user have access to the object. Therefore, if a user is denied access to an object either through his or her own user account or through any role (previously known in SQL 6.5 as groups) he or she belongs to, then the user will not be given access to the object.

The REVOKE statement
The REVOKE statement simply indicates that a previously assigned security setting should be undone. For example, if a user had previous access to a table with the GRANT statement, the REVOKE statement would undo that GRANT (note that the user may still have access to the table through one of the roles he or she belongs to). On the other hand, if the user had been denied access to the table at the user level, the REVOKE statement would delete (or undo) that denial.

The SQL Server security system allows for the definition of roles. An interesting note about the SQL Server security system is that role access is hierarchical, meaning that a SQL Server role can contain other SQL Server roles. As a result, whenever a hierarchical structure is put in place, user access can quickly become very difficult to manage or to determine. The user will receive the union of all of the permissions that have been granted to the user or to any one of the roles to which the user belongs, with denials taking precedence over grants—i.e., one denial anywhere in the chain and the user has no access.

Column-level security
Column-level security is a relatively simple matter as all the components necessary are built into the internal SQL Server security system. Access to any column can be secured with the SQL Server GRANT, REVOKE, and DENY statements (programmatically through DMO, or through the Enterprise manager). The statement in Listing A provides SELECT permissions on the stor_id, ord_num, ord_date, qty, and title_id columns of the sales table in the pubs database to the user b_smith. The sales table in the pubs database has another column the payterms column, which is not included in Listing A. Therefore, the statement in Listing A effectively gives the user the ability to view any column except the payterms column. At the column level, SELECT and UPDATE permissions can be assigned to any user or role.

SQL Server does not provide an internal method of securing individual rows in the database. However, by using SQL Server views, it’s possible to provide row-level security without too much effort. The primary component in a row-level security system is the use of views. Creating a view that resides on top of the table and giving the user access to the view but not the underlying table can enforce an effective row-level security system. The statement in Listing B demonstrates the creation of a single view per user approach. This view limits the records b_smith can access to only those from store 6380 (presumably the store where b_smith works). The statement also uses the WITH CHECK OPTION view option. This option prevents a user of the view (b_smith, in this case) from inserting a record that he or she would not be able to retrieve later. (In this case, b_smith would not be able to insert a record with a stor_id of any value other than 6380.) One disadvantage of this approach is that it requires views to be created for each role or user.

More complicated views are used to provide row-level access to a table. These views generally provide a single view, as opposed to one per user, incorporating all of the row-level security mechanisms of all of the users in the database. This technique offers the advantage of easier administration since there are fewer views to keep track of, which subsequently translates into less code (our favorite advantage).

Database security is worth the extra effort
Providing a fully functional system for securing your database is a significant yet often overlooked step in developing a well-rounded application security system. It’s often tempting to enforce security only within the application itself, with a single password giving all users access to the database. This entails less work, but it often leaves too many open holes in the database for crackers to exploit. (It’s not difficult to connect to a SQL Server database using Access—a user doesn’t even have to know SQL.) It’s a little more work to provide a robust security system at the database level, but the consequences of not doing so far outweigh the costs.

Listing A

USE PUBS
GRANT SELECT
(stor_id,
ord_num,
ord_date,
qty,
title_id)
ON sales
TO b_smith
Listing B

USE PUBS
CREATE
VIEW b_smith__sales
AS
SELECT *
FROM sales
WHERE stor_id = 6380
WITH CHECK OPTION

Pemulihan SQL Server dari kondisi Kegagalan
(SQL Server Disaster Recovery )
Bagian 1. Pendahuluan.
Setelah menyelesaikan proses instalasi dan konfigurasi terhadap MS SQL Server, setiap administrator basisdata dapat beristirahat. Tetapi, hal penting yang harus diingat bahwa proses administrasi basisdata tidak berakhir ketika basisdata tersedia secara lancara untuk menjawab kebutuhan permintaan. Kita harus mempertimbangkan banyak hal selama perancangan basisdata, yaitu : unjuk kerja, kendali akses-kendali akses, strategi replikasi, normalisasi, dan peng-indeks-an.
Sudahkah kita mengambil waktu untuk mengembangkan rencana kontingensi untuk memenuhi kemungkinan beberapa hal yang mungkin akan mempengaruhi basisdata di masa yang akan datang ?
Pemulihan dari kondisi kegagalan seringkali diabaikan sehingga penanganannya akan terlambat ketika sudah terjadi. Administrator-administrator basisdata yang sibuk secara mudahnya meremehkan tugas ini dengan janji akan membenahi cadangan (backup) yang benar setelah menyelesaikan proyek yang besar ini. Tetapi ambil waktu sebentar dan pertimbangkan nilai data dari perusahaan. Apa akibatnya jika waktu yang berharga dari perubahan basisdata yang kemudian hilang ? Sehari ? Bagaimana dengan kehilangan keseluruhan dari basisdata ?

Kebanyakan jawaban yang serupa untuk menjawab pertanyaan tersebut adalah sebuah rencana yang komprehensif untuk pemulihan dari kondisi kegagalan. Mereka juga akan membentuk kondisi awal dari rencana pengembangan spesifik terhadap kebutuhan perusahaan. Di akhir sub bab ini, kita akan melihat faktor-faktor lain untuk dipertimbangkan ketika mengembangkan sebuah strategi untuk perusahaan. Dua sub bab berikutnya akan menguji dua mekanisme pemulihan dari kondisi kegagalan yang ditawarkan oleh Microsoft SQL Server (dan basisdata lainnya), yaitu cadangan basisdata (database backups) dan catatan transaksi (transaction logs).
Langkah pertama dalam pengembangan rencana pemulihan dari kondisi kegagalan adalah ide dari kebijakan apa yang dapat menerima kerugian dari perusahaan. Pertama, pertimbangkan akibat dari kehilangan data yang tersimpan dalam basisdata.
Apakah kita sanggup untuk mengembalikan dari kerugian waktu berharga dari data ? Jika kita menangani basisdata dari sumber daya manusia, kemungkinan penanganannya adalah dengan menginstruksikan kepada bawahan untuk memasukkan ulang data yang telah dimasukkan selama perioda tersebut. Jika kita menjalankan basisdata yang menunjang institusi finansial, kerugian dari waktu berharga data akan memberikan dampak langsung ke pelanggan dan pengatur industri sepanjang kerugian moneter secara signifikan. Proteksi terhadap tipe-tipe kerugian ini disediakan oleh cadangan (backup) dari basisdata dan penggunaan catatan transaksi (transaction logging). Kita akan membahasnya kemudian secara lebih mendetail.
Kedua, pertimbangkan kerugian dari akses ke basisdata itu sendiri. Apakah yang akan menjadi dampak utama jika pengguna tidak dapat mengakses informasi untuk periode waktu tertentu.
Ketidakmampuan mengakses basisdata akan mengakibatkan frustasi, tetapi kerugian minimal ke bisnis. Pada kasus lain, jika seorang dokter pada sebuah rumah sakit tidak mampu mengakses pencarian hasil tes laboratorium pada suatu waktu yang mendesak maka akan mengakibatkan kehilangan nyawa atau kecacatan. Jika kita menemukan kasus yang berhubungan dengan organisasi, maka kita akan mempertimbangkan penggunaan clustering untuk memastikan kelanjutan dari ketersediaan basisdata. Konsep ini akan dibicarakan dalam subbab berikutnya.

Sekali kita menentukan tingkat penerimaan kerugian dari organisasi dan penerimaan pembelian dari pengguna yang kita dukung dan manajemen, maka ini waktunya untuk mulai mengembangkan strategi untuk mengurangi dampak dari kejadian yang buruk dari basisdata. Langkah pertama adalah mengembangkan strategi cadangan (backup) secara menyeluruh.

Bagian 2: Cadangan Basisdata (Database Backup)

Microsoft SQL Server 2000 menawarkan 2 mekanisme cadangan basisdata – “full backup” dan “differential backup”. Anda akan perlu untuk mengukur biaya dan keuntungan ketika menjadwalkan cadangan (backup) data organisasi.
“Full backup” akan menyimpan keseluruhan salinan (copy) basisdata pada setiap media penyimpanan yang mendukung. SQL Server 2000 mendukung Microsoft Tape Format (MSTF) untuk cadangan (backup) ke dalam bentuk tape, disk dan dinamakan “pipe”. “Full backup” dapat dibentuk tanpa mengambil basisdata offline, tetapi banyak menghabiskan sumber daya sistem dan perlu dicatat dampak terhadap waktu respon dari basisdata (database response times).
“Differential backup” dirancang untuk mengkompensasi sejumlah besar waktu untuk membentuk “full backup”, yang akan membentuk suatu mekanisme yang mirip pada saat menyimpan salinan jika hanya data telah berubah sejak terakhir “full backup”. Kebanyakan basisdata mengandung sejumlah besar informasi yang tidak sering berubah. Untuk kasus ini, “differential backup” akan lebih sedikit menghabiskan sumber daya dibandingkan “full backup” dan dapat memproses secara signifikan tidak akan mengganggu unjuk kerja basisdata.
Sangat kritis untuk diingat bahwa “differential backup” hanya mengandung data yang diubah sejak terakhir “full backup”. Pada saat kegagalan (failure) basisdata, sebuah “differential backup” tersendiri akan tidak berguna. Sebagai contoh, bayangkan bahwa perusahaan XYZ membentuk “full backup” setiap hari Jumat pada saat kantor tutup dan “differential backup” pada hari Senin sampai hari Kamis malam. Jika basisdata gagal (fail) pada hari Rabu pagi, administrator basisdata akan pertama kali mengembalikan (restore) data dari “full backup” hari Jumat sebelumnya dan mengaplikasikan “differential backup” hari Kamis malam untuk memberikan basisdata suatu tingkat cadangan terbaru.
Sekali lagi, penggabungan secara eksak dari “full backup” dan “differential backup” bergantung pada variasi faktor yang unik dari organisasi. Pertimbangkan lamanya waktu yang diperlukan untuk membentuk “backup” dan dampak yang mungkin terjadi terhadap basisdata. Jika basisdata hanya digunakan selama jam kerja, maka kita dapat menjadwalkan “full backup” untuk dijalankan setiap malam setelah kantor tutup. Pada kasus lain, jika anda mendukung operasi 24-jam, maka penjadwalan “full backup” diselipkan pada waktu malam Minggu dan penggunaan “differential backup” pada waktu malam hari sebagai tambahan.
Ketika mengembangkan strategi mengembalikan kegagalan (disaster recovery) anda harus mempertimbangkan pula media penyimpanan untuk cadangan basisdata. Jika anda membuat cadangan ke dalam bentuk tape dan menyimpan tape tesebut di dalam ruangan server, maka tidak akan memberikan keuntungan ketika api menghanguskan ruangan server. Akan lebih baik untuk menyimpan salinan (copy) dari tape di luar lingkungan yang aman.
Kita telah membicarakan metoda yang digunakan untuk mencadangkan isi basisdata. Secara ideal, kita mampu membentuk “full database backup” setiap basisdata diubah. Sayangnya, ini adalah impian (pipe dream) untuk kebanyakan implementasi basisdata – sejumlah besar waktu dan sumber daya yang dibutuhkan untuk membentuk cadangan akan membatasi kita untuk menjadwalkan “differential backup” pada basis yang tidak teratur — mungkin harian atau mungkin setiap jam tergantung keadaan. Tetapi, SQL Server tidak menyediakan mekanisme untuk mengkompensasi perubahan basisdata yang dibuat selama periode waktu antara cadangan — “transaction log”. Kita akan mendiskusikan “transaction log backup” dalam subbab berikutnya.

Bagian 3: Transaction Log

Dalam sub bab sebelumnya kita telah membahas proteksi data yang disediakan oleh “full backup” dan “differential backup”. Pada kebanyakan situasi, biaya untuk membentuk cadangan skala besar (large-scale backup) melarang kita untuk melakukannya selama periode sibuk, seperti jam kantor. Tetapi, kegagalan (failure) untuk membentuk cadangan (backup) selama jam kantor dapat berakibat hilangnya keseluruhan data jika basisdata gagal (fail) sebelum cadangan dibentuk. Untunglah, SQL Server menyediakan kemampuan “backup transaction log” — suatu fitur yang menyediakan mekanisme yang efisien untuk menurunkan kehilangan sejumlah besar data yang potensial.
Selama operasi normal, SQL Server memanfaatkan “transaction log” untuk menelusuri keseluruhan modifikasi yang dibentuk di dalam basisdata. “Log” ini memastikan basisdata mampu dikembalikan ketika dihentikan secara paksa (seperti mati listrik) dan pengguna tidak mampu membatalkan (atau “rollback” dalam istilah basisdata) hasil dari transaksi basisdata. Transaksi yang belum selesai akan dipelihara di dalam “log” sebelum secara permanen disimpan(atau dikenal dengan istilah “committed”) dalam basisdata. Kegunaan dari “transaction log backup” memampukan kita untuk menyimpan salinan “transaction log” dari basisdata pada sebuah perangkat cadangan (backup device). Cadangan (Backup) dengan cara ini secara umum lebih sedikit menghabiskan sumber daya daripada “full backup” atau “differential backup” dan oleh karena itu sangat cocok untuk periode jam sibuk.
Setiap waktu “transaction log” dibuat cadangannya, SQL Server akan menghapus keseluruhan “committed transactions” di dalam “log” dan menuliskan ke media penyimpan cadangan. Terhadap proses inkremental ini, “transaction log” tidak akumulatif dan kita harus memelihara kumpulan “transaction logs” secara keseluruhan untuk mencapai “full backup” atau “differential backup” yang paling baru. Sebagai contoh, kita lihat organisasi yang disebut sebagai perusahaan XYZ membentuk “full backup” pada jam tutup kantor setiap hari Jumat dan “differential backup” setiap hari Senin sampai hari Kamis malam. Mari kita ambil strategi ini satu langkah lebih jauh dan memasukkan “backup” setiap jam dari “transaction log” selama jam kerja. Asumsikan basisdata gagal pada 11:05AM hari Rabu. Dari strategi sebelumnya, kita menggunakan hari Jumat “full backup” dan hari Kamis untuk “differential backup” untuk mengembalikan basisdata ke tingkat tutupnya kerja pada hari Kamis. Ini berakibat hilangnya 2 jam data (9-11AM hari Rabu). Penggunaan strategi baru dengan menambahkan “transaction log backup”, kita dapat mengaplikasikan jam 9AM dan jam 10AM “transaction log backup” setelah hari Kamis “differential backup” untuk mengembalikan basisdata ke tingkat 11AM hari Rabu. Sekarang kita telah mengatur pemulihan keseluruhan tetapi 5 menit dari aktifitas basisdata, secara jelas melakukan perbaikan.
Contoh sebelumnya menyoroti pentingnya strategi cadangan secara komprehensif. Perusahaan XYZ menggunakan basisdata dan hasil “transaction log backup” dalam model penanganan kegagalan dimana tidak lebih dari 1 jam data kan hilang untuk kondisi terburuk dengan dampak minimal terhadap unjuk kerja sistem. Anda dapat meniru contoh ini dan mengubahnya sesuai dengan kebutuhan yang ditentukan untuk organisasi.
Sekarang setelah membahas pemulihan kegagalan, ini saatnya untuk memulai untuk mengembangkan rencana pemulihan kegagalan terhadap basisdata. Pertimbangkan untuk melibatkan pelanggan internal dan tim manajemen dalam proses ini.

Bekerja dengan stored procedure

Bab ini menguraikan bagaimana cara menggunakan stored procedure di (dalam) aplikasi database mu. Suatu stored procedure adalah suatu program disatukan memberi suara prosedur dan bahasa picu dikhususkan untuk sistem database menggunakan. Ada dua pokok jenis stored procedure. jenis Yang pertama mendapat kembali data ( seperti dengan suatu MILIH query). data Yang didapat kembali dapat dalam wujud yang dataset terdiri dari atau lebih [] baris data, dibagi menjadi satu atau lebih kolom. Atau data yang didapat kembali dapat dalam wujud potongan individu informasi. Jenis yang kedua tidak kembali[kan data, tetapi melaksanakan suatu tindakan pada [atas] data disimpan di (dalam) database ( seperti dengan suatu HAPUS statemen). Beberapa pen;dukungan server database yang melakukan/menyelenggarakan kedua jenis operasi di (dalam) prosedur yang sama [itu].

Stored procedure yang kembali[kan data melakukannya di (dalam) jalan berbeda, tergantung pada bagaimana stored procedure terdiri dan sistem database digunakan. Beberapa, [seperti;suka] Interbase, kembali[kan semua data ( datasets dan potongan individu informasi) [yang] eksklusif dengan parameter keluaran. (Orang) yang lain adalah mampu untuk mengembalikan suatu cursor ke data. Dan masih (orang) yang lain, [seperti;suka] MICROSOFT SQL Server dan Sybase, dapat kembali[kan suatu dataset dan potongan individu informasi.

Di (dalam) Delphi aplikasi, akses [bagi/kepada] stored procedure disajikan oleh TSTOREDPROC dan TQUERY komponen. Pilihan [di/yang mana] untuk menggunakan untuk akses adalah predicated pada [atas] bagaimana stored procedure coded, bagaimana data dikembalikan ( bila ada), dan sistem database menggunakan. TSTOREDPROC dan TQUERY komponen adalah kedua-duanya keturunan TDATASET, dan menerima warisan perilaku dari TDATASET. Karena lebih [] informasi tentang TDATASET, lihat ” Pemahaman datasets.”

Suatu komponen stored procedure digunakan untuk melaksanakan stored procedure yang jangan kembalikan manapun data, untuk mendapat kembali potongan individu informasi dalam wujud parameter keluaran, dan untuk menyiarkan ulang suatu dataset dikembalikan [bagi/kepada] suatu komponen sumber data dihubungkan ( ini akhir menjadi database-specific). komponen stored procedure mengijinkan nilai-nilai untuk diberikan kepada dan kembali dari stored procedure melalui/sampai parameter, masing-masing parameter digambarkan di (dalam) [itu] Params hak milik. komponen stored procedure juga menyediakan suatu Getresults metoda untuk memaksa stored procedure untuk kembali[kan suatu dataset ( beberapa server database memerlukan ini [sebelum/di depan] suatu hasil di-set diproduksi). komponen stored procedure menjadi alat-alat yang lebih disukai untuk . yang menggunakan stored procedure yang baik jangan kembalikan manapun data maupun hanya kembali[kan data melalui/sampai parameter keluaran.

Suatu komponen query terutama semata digunakan untuk stored procedure lari yang kembali[kan datasets. Ini meliputi Interbase menyimpan prosedur yang hanya kembali[kan datasets via parameter keluaran. query Komponen dapat juga digunakan untuk melaksanakan suatu stored procedure yang tidak kembali[kan suatu dataset atau nilai-nilai parameter keluaran.

penggunaan Parameter untuk memberikan nilai-nilai beda pada atau kembali[kan nilai-nilai dari suatu stored procedure. parameter Nilai-Nilai digunakan dalam tempat yang sedemikian maupun [sebagai/ketika] [DI MANA/JIKA] anak kalimat/ketentuan suatu MILIH statemen di (dalam) suatu stored procedure. Suatu parameter keluaran mengijinkan suatu stored procedure untuk memberikan nilai tunggal pada [itu] pemanggilan aplikasi. Beberapa stored procedure kembali[kan suatu parameter hasil. Dokumentasi untuk server database [yang] yang spesifik [yang] kamu sedang penggunaan untuk detil pada [atas] jenis parameter yang didukung dan bagaimana mereka digunakan di (dalam) bahasa prosedur server.

Kapan sebaiknya kamu menggunakan stored procedure?

Jika server mu menggambarkan stored procedure, kamu perlu menggunakan [mereka/nya] jika mereka [berlaku bagi/meminta kepada] kebutuhan [dari;ttg] aplikasi mu. Suatu pengembang server database menciptakan stored procedure untuk menangani tugas terkait dengan database frequently-repeated. Sering, operasi yang berlaku [atas/ketika] sejumlah besar baris di (dalam) database tables–or yang menggunakan kumpulan atau mathematical functions–are calon untuk stored procedure. Jika stored procedure ada pada [atas] server database yang remote penggunaan aplikasi mu, kamu perlu mengambil keuntungan dari di antara mereka di (dalam) aplikasi mu. Kesempatan adalah kamu memerlukan sebagian dari kemampuan [yang] mereka menyediakan, dan kamu berpegang kepada meningkatkan capaian [dari;ttg] aplikasi database mu oleh:

* Ambil keuntungan dari [menyangkut] daya proses [yang] lebih besar server dan kecepatan.

* Urangi jumlah lalu lintas jaringan karena pengolahan berlangsung pada [atas] server [di mana/jika] data berada.

Sebagai contoh, mempertimbangkan suatu aplikasi yang harus menghitung nilai tunggal: simpangan baku berharga (di) atas sejumlah besar arsip. Untuk melaksanakan fungsi ini di (dalam) aplikasi mu, semua nilai-nilai digunakan di (dalam) perhitungan harus diambil dari server, menghasilkan lalu lintas jaringan ditingkatkan. Kemudian aplikasi mu harus melaksanakan perhitungan [itu]. Sebab semua kamu ingin di (dalam) aplikasi mu menjadi akhir [itu] result–a nilai tunggal mewakili standard [itu] deviation–it akan bersifat efisien lebih [yang] jauh untuk suatu stored procedure pada [atas] server untuk membaca data [yang] disimpan [di/ke] sana, melaksanakan kalkulasi, dan lewat aplikasi mu [adalah] nilai yang tunggal [itu] memerlukan.

Dokumentasi database server Mu untuk lebih [] informasi tentang itu mendukung untuk stored procedure.

Penggunaan suatu stored procedure

Bagaimana suatu stored procedure digunakan di (dalam) suatu Delphi aplikasi tergantung pada bagaimana stored procedure coded, apakah dan bagaimana [itu] kembali[kan data, server database yang spesifik menggunakan, atau suatu kombinasi [dari;ttg] faktor ini.

Pada garis besarnya, untuk mengakses suatu stored procedure pada [atas] suatu server, suatu aplikasi harus:

1. Instantiate [adalah] suatu TSTOREDPROC komponen dan secara bebas pilih berhubungan ia/nya dengan suatu stored procedure pada [atas] server [itu]. Atau instantiate [adalah] suatu TQUERY komponen dan menyusun [muatan/indeks] tentang SQL hak milik nya untuk melaksanakan yang manapun suatu MILIH query melawan terhadap stored procedure atau suatu LAKSANAKAN perintah, tergantung pada apakah stored procedure kembali[kan suatu hasil menetapkan. Karena lebih [] informasi tentang menciptakan suatu TSTOREDPROC, lihat ” Menciptakan suatu komponen stored procedure”. Karena lebih [] informasi tentang menciptakan suatu TQUERY komponen, lihat ” Bekerjasama dengan query”.

2. Sediakan[lah parameter masukan menilai kepada komponen stored procedure, jika perlu. Ketika suatu komponen stored procedure tidaklah dihubungkan dengan stored procedure pada [atas] suatu server, kamu harus menyediakan informasi parameter masukan tambahan, seperti jenis data dan nama parameter. Karena lebih [] informasi tentang menyediakan informasi parameter masukan, lihat ” Pengaturan informasi parameter pada waktu disain”.

3. Laksanakan[lah stored procedure [itu].

4. Mproses[lah manapun parameter keluaran dan hasil. [Seperti/Ketika] dengan dataset komponen lain, kamu dapat juga menguji hasil [itu] dataset kembali dari server [itu]. Karena lebih [] informasi tentang keluaran dan parameter hasil, lihat ” Penggunaan parameter keluaran” dan ” Gunakan parameter hasil”. Karena informasi tentang arsip yang mengamati di (dalam) suatu dataset, lihat ” Penggunaan stored procedure yang kembali[kan hasil menetapkan”.

Menciptakan suatu komponen stored procedure

Untuk menciptakan suatu komponen stored procedure untuk suatu stored procedure pada [atas] suatu server database:

1. Nempatkan[lah suatu komponen stored procedure dari akses data Halaman dari komponen Palet(Lukis) di (dalam) suatu modul data.

2. Secara bebas pilih menetapkan Databasename hak milik dari komponen stored procedure kepada nama dari database di mana stored procedure digambarkan. Databasename harus suatu BDE alias atau nilai yang sama seperti di Databasename hak milik suatu TDATABASE yang dapat menghubungkan kepada server [itu].

Secara normal kamu perlu menetapkan Databasename hak milik, tetapi jika database server dibanding dengan aplikasi mu berlari sekarang ini tak tersedia, kamu kaleng masih menciptakan dan menyediakan suatu komponen stored procedure dari [oleh/dengan] penghilangan Databasename dan penyediaan [adalah] suatu stored procedure menyebut dan masuk, keluaran, dan menghasilkan parameter pada waktu disain. Karena lebih [] informasi tentang parameter masukan, lihat ” Penggunaan parameter masukan”. Karena lebih [] informasi tentang parameter keluaran, lihat ” Penggunaan parameter keluaran”. Karena lebih [] informasi tentang parameter hasil, lihat ” Gunakan parameter hasil”.

3. Secara bebas pilih menetapkan Storedprocname hak milik kepada nama dari stored procedure untuk menggunakan. Jika kamu menyajikan suatu nilai untuk Databasename hak milik, kemudian kamu dapat memilih suatu stored procedure menyebut dari drop-down mendaftar untuk hak milik [itu]. TSTOREDPROC komponen Tunggal dapat digunakan untuk melaksanakan manapun jumlah stored procedure [oleh/dengan] pengaturan Storedprocname hak milik [bagi/kepada] suatu nama sah di (dalam) aplikasi [itu]. Mungkin tidak selalu (adalah) diinginkan untuk menetapkan Storedprocname pada waktu disain.

4. Double-Click [adalah] Params nilai tanah milik kotak untuk memohon Storedproc parameter Editor untuk menguji parameter keluaran dan masukan untuk stored procedure [itu]. Jika kamu tidak menetapkan suatu nama untuk stored procedure sejalan 3, atau kamu menetapkan suatu nama untuk stored procedure yang tidak ada pada [atas] server ditetapkan di (dalam) Databasename hak milik sejalan 2, kemudian ketika kamu memohon editor parameter, itu kosong.

Tidak semua server kembali[kan informasi parameter atau parameter. dokumentasi server Mu untuk menentukan apa [yang] informasi tentang itu menyimpan prosedur [itu] kembali ke aplikasi klien.

Catatan: Jika kamu tidak menetapkan Databasename hak milik sejalan 2, kemudian kamu harus menggunakan Storedproc parameter Editor untuk menyediakan parameter pada waktu disain. Karena informasi tentang pengaturan parameter pada waktu disain, lihat ” Pengaturan informasi parameter pada waktu disain”.

Menciptakan suatu stored procedure

Biasanya, menyimpan prosedur diciptakan ketika aplikasi dan database nya diciptakan, menggunakan perkakas yang disediakan oleh penjual sistem database. Bagaimanapun, adalah mungkin untuk menciptakan stored procedure pada runtime. SQL statemen Yang spesifik yang digunakan akan bertukar-tukar dari [satu/ orang] database sistem [bagi/kepada] yang lain sebab bahasa prosedur bervariasi maka sangat. Konsultasi[lah dokumentasi untuk sistem database [yang] yang spesifik [yang] kamu sedang penggunaan untuk bahasa prosedur yang didukung.

Suatu stored procedure dapat diciptakan oleh suatu aplikasi pada runtime dengan menggunakan suatu SQL statemen mengeluarkan dari suatu TQUERY komponen, [yang] secara khas dengan suatu MENCIPTAKAN statemen PROSEDUR. Jika parameter digunakan di (dalam) stored procedure, menetapkan Paramcheck hak milik DARI TQUERY ke Sumbang/Palsu. Ini mencegah TQUERY dari mistaking parameter di (dalam) prosedur [yang] disimpan yang baru dari suatu parameter untuk TQUERY itu sendiri .

Catatan: Kamu dapat juga menggunakan SQL Penjelajah untuk menguji, mengedit, dan menciptakan stored procedure pada [atas] server [itu].

Setelah SQL hak milik telah didiami dengan statemen untuk menciptakan stored procedure, melaksanakan ia/nya itu sendiri [oleh/dengan] permohonan Execsql metoda.

with Query1 do begin
Paramcheck := False;
With SQL do begin
Clear;
Add(‘CREATE PROCEDUR GET_MAX_EMP_NAME’);
Add(‘RETURNS ( Max_Name CHAR(15))’);
Add(‘AS’);
Add(‘BEGIN’);
Add(‘ SELECT MAX(LAST_NAME)’);
Add(‘ FROM EMPLOYEE’);
Add(‘ INTO : Max_Name;’);
Add(‘ SUSPEND;’);
Add(‘End’);
end;
Execsql;
end;

Siapkan dan melaksanakan suatu stored procedure

Untuk menggunakan suatu stored procedure, kamu kaleng [yang] secara bebas pilih siap[kan itu, dan kemudian melaksanakan itu.

Kamu dapat siap[kan suatu stored procedure pada:

* disain Waktu, [oleh/dengan] memilih OK di (dalam) parameter Editor.

* Runtime, [oleh/dengan] pemanggilan Siap[Kan metoda dari komponen stored procedure.

Sebagai contoh, kode berikut siap[kan suatu stored procedure untuk pelaksanaan:

Storedproc1.Prepare;

Catatan: Jika aplikasi mu ber;ubah informasi parameter pada runtime, seperti ketika penggunaan Oracle memuat berlebih prosedur, kamu perlu siap[kan prosedur lagi.

Untuk melaksanakan suatu stored procedure disiapkan, [panggil/hubungi] Execproc metoda untuk komponen stored procedure. Kode berikut menggambarkan kode yang siap[kan dan melaksanakan suatu stored procedure:

Storedproc1.Params[0].Asstring:= Edit1.Text;

Storedproc1.Prepare;

Storedproc1.Execproc;

Catatan: Jika kamu mencoba untuk melaksanakan suatu stored procedure [sebelum/di depan] menyiapkan itu, komponen stored procedure [yang] secara otomatis siap[kan ia/nya untuk kamu, dan kemudian unprepares [itu] setelah [itu] melaksanakan. Jika kamu merencanakan untuk melaksanakan suatu stored procedure sejumlah waktu, [itu] jadilah lebih efisien untuk [panggil/hubungi] Siap[Kan (diri) sendiri, dan kemudian hanya [panggil/hubungi] Tidak siap[kan sekali ketika, ketika kamu tidak lagi harus melaksanakan prosedur [itu].

Ketika kamu melaksanakan suatu stored procedure, [itu] dapat kembali[kan semua atau sebagian dari materi ini:

* Yang dataset terdiri dari atau lebih [] arsip yang dapat dipandang di (dalam) data-aware kendali dihubungkan dengan stored procedure melalui suatu komponen sumber data.

* keluaran Parameter.

* Suatu parameter hasil yang berisi informasi status tentang menyimpan pelaksanaan prosedur.

Untuk menentukan materi kembalian untuk harapkan dari suatu stored procedure pada [atas] server mu, lihat dokumentasi server mu.

Penggunaan stored procedure yang memberikan susunan hasil
Stored procedure memberikan data di (dalam) datasets, kolom dan baris data, perlu paling sering digunakan di suatu komponen query. Bagaimanapun, dengan server database yang mendukung mengembalikan suatu dataset oleh suatu stored procedure, suatu komponen stored procedure dapat melakukan seperti diminta ini .

Mendapat kembali suatu hasil menata suatu TQUERY

Untuk mendapat kembali suatu dataset dari suatu stored procedure [yang] menggunakan suatu TQUERY komponen:

1. Instantiate suatu komponen query.

2. Di (dalam) TQUERY.SQL hak milik, tulis suatu SELECT query yang menggunakan nama dari stored procedure sebagai ganti suatu nama [tabel;meja].

3. Jika stored procedure memerlukan parameter masukan, menyatakan parameter menilai sebagai daftar comma-separated, melampirkan di (dalam) tanda kurung, mengikuti nama prosedur.

4. yang di-set hak milik Yang Active ke True atau memohon metoda Yang terbuka [itu].

Sebagai contoh, Interbase menyimpan prosedur GET_EMP_PROJ, di bawah, menerima nilai parameter masukan EMP_NO dan mengembalikan dataset sehingga memunculkan parameter keluaran PROJ_ID.

CREATE PROCEDURE GET_EMP_PROJ (EMP_NO SMALLINT)
RETURNS (PROJ_ID CHAR (5) )
AS
BEGIN
FOR SELECT PROJ_ID
FROM EMPLOYEE_PROJECT
WHERE EMP_NO = :EMP_NO
INTO :PROJ_ID
DO
SUSPEND;
END

Pernyataan SQL yang diambil dari TQuerry dengan menggunakan stored procedure ini akan menjadi:

SELECT *
FROM GET_EMP_PROJ (52)

Mengambil hasil dengan TStoredProc
Untuk mengambil dataset dari stored procedure menggunakan komponen TStoredProc :
1. Instantiate sebuah komponen prosedur penyimpanan.
2. Di dalam properti StoredProcName, khususnya nama dari stored procedure.
3. Jika stored procedure memerlukan paremeter masukan, masukan nilai untuk parameter menggunakan properti Params atau metode ParamByName.
4. Susun properti yang Active menjadi True atau memohon metode Open.

Sebagai contoh, prosedur Sybase GET_EMPLOYEES. dibawah, menerima parameter masukan dengan nama @EMP_NO dan memeberikan hasil berdasarkan nilai.

CREATE PROCEDURE GET EMPLOYEES @EMP_NO SMALLINT
AS SELECT EMP_NAME, EMPLOYEE_NO FROM EMPLOYEE_TABLE
WHERE (EMPLOYEE_NO = @EMP_NO)

Kode Delphi untuk mengisi parameter dengan nilai dan mengaktifkan komponen stored procedure adalah:

with StoredProc1 do begin
Close;
ParamByName (‘EMP_NO’).AsSmallInt := 52;
Active := True;
end;

Menggunakan stored procedure yang memberikan data menggunakan parameter
Prosedur yang yang disimpan dapat disusun untuk mengambil informasi individu, seperti [opposed] semua baris data, dari parameter.
Singkatnya stored procedure dapat mengambil hingga nilai maksimum untuk kolom, masukan satu ke dalam nilai, kemudian kembalikan nilai tadi ke aplikasi.Stored procedure dapat digunakan dan nilai yang diperkirakan dengan menggunakan TQuery atau komponen TStoredProc.
Di sarankan menggunakan metoda TStoredProc untuk mengambil nilai parameter.

Mengambil nilai individu dengan TQuery
Nilai parameter mengambil komponen TQuery mengambil form dataset dari baris single, walaupun satu parameter dikembalikan oleh stored procedure.
Untuk mengambil nilai individu dari stored procedure parameter menggunakan komponen TQuery:
1. Instantiate suatu komponen query.

2. Di (dalam) TQUERY.SQL hak milik, tulis SELECT query yang menggunakan nama dari stored procedure sebagai ganti suatu table nama. Kata SELECT dari query ini dapat mengenali parameter dari namanya, seperti bila kita ada di kolom tabel, atau kita dapat menggunakan operasi * untuk mengambil semua nilai parameter.

3. Jika stored procedure memerlukan parameter masukan, menyatakan parameter menilai sebagai daftar comma-separated, melampirkan di (dalam) tanda kurung, mengikuti nama prosedur.

4. yang di-set hak milik Yang aktip ke Benar atau memohon metoda Yang terbuka [itu].

Sebagai contoh, prosedur InterBase yang disimpan GET_HIGH_EMP_NAME, dibawah ini, mengambil nilai alfabet terakhir ke dalam kolom LAST_NAME dari tabel nama EMPLOYEE.Stored procedure memberikan nilai ini ke keluaran parameter High_Last_Name.

CREATE PROCEDURE GET_HIGH_EMP_NAME
RETURNS (High_Last_Name CHAR (15))
AS
BEGIN
SELECT MAX (LAST NAME)
FROM EMPLOYEE
INTO : High_Last_Name;
SUSPEND;
END

Pernyataan SQL yang diambil dari TQuerry dengan menggunakan stored procedure ini akan menjadi:

SELECT High_Last_Name
FROM GET_HIGH_EMP_NAME

Mengambil nilai individu dengan TStoredProc
Untuk mengambil nilai individual dari parameter keluaran stored procedure menggunakan komponen TStoredProc :

1. Instantiate sebuah komponen prosedur penyimpanan.
2. Dalam properti StoredProcName, khususkan nama dari stored procedure.
3. Jika stored procedure memerlukan parameter masukan, masukan nilai untuk parameter menggunakan properti Params ata metoda ParamByName.
4. memohon metoda ExecProc.
5. Periksa nilai dari keluaran parameter individu dengan menggunkan properti Params atau metoda ParamByName.

Sebagai contoh, prosedur InterBase yang disimpan GET_HIGH_EMP_NAME, dibawah ini, mengambil nilai alfabet terakhir ke dalam kolom LAST_NAME dari tabel nama EMPLOYEE.
Stored procedure mengembalikan nilai ini ke keluaran parameter High_Last_Name.

CREATE PROCEDURE GET_HIGH_EMP_NAME
RETURNS (High_Last_Name CHAR (15))
AS
BEGIN
SELECT MAX (LAST NAME)
FROM EMPLOYEE
INTO : High_Last_Name;
SUSPEND;
END

Kode Delphi yang diambil dari nilai parameter keluaran High_Last_Name dan menyimpannya ke properti Text dari komponen TEdit akan menjadi:
with StoredProc1 do begin
StoredProcName := ‘ Get_High_Emp_Name’;
ExecProc;
Edit1.Text := ParamByName (‘High_Last_Name’).AsString;
end;

Menggunakan stored procedure untuk menunjukan aksi pada data
Stored procedure dapat diberi kode agar dapat mengembalikan data, dan hanya menunjukan beberapa aksi di datbase. Operasi SQL mencakup penyataan INSERT dan DELETE yang merupakan contoh yang bagus untuk tipe dari stored procedure. Singkatnya adalah memperbolehkan pengguna untuk menghapus baris, stored procedure dapat digunakan juga untuk hal diatas. Dengan ini dapat stored procedure dapat juga digunakan untuk mengontrol apasaja yang akan dihapus dan juga untuk menangani aspek [referential integrity], seperti menyusun baris yang dapat dihapus dalam table yang berdiri sendiri.

Menjalankan aksi stored procedure dengan Tquery
Untuk menjalakan aksi stored procedure dengan menggunkan komponen Tquery:
1. Instantiate suatu komponen query.
2. Dalam property Tquery.SQL, termasuk perintah yang dibutuhkan untuk menjalakn stored procedure dan nama dari stored procedure. ( perintah untuk menjalakan stored procedure dapat bervariasi dari system database yang satu ke system database yang lain. Di dalam InterBase, perintahnya adalah EXECUTE PROCEDURE ).
3. Jika stored procedure memerlukan parameter masukan, tunjukan nilai dari parameter sebagai daftar comma-separated, melampirkan di dalam tanda kurung, mengikuti prosedur nama.
4. Memohon metoda Tquery.ExecSQL.
Sebagai contoh, prosedur InterBase yang disimpan ADD_EMP_PROJ, dibawah, masukan baris baru untuk table EMPLOYEE_PROJECT. Tidak ada dataset yang dikempbalikan dan tidak ada nilai individu yang dikeblaikan dari parameter keluaran.

CRETE PROCEDURE ADD_EMP_PROJ (EMP_NO SMALLINT, PROJ_ID CHAR(5))
AS
BEGIN
BEGIN
INSERT INTO EMPLOYEE_PROJECT (EMP_NO, PROJ_ID);
VALUES (:EMP_NO, :PROJ_ID);
WHEN SQLCODE –530 DO
EXCEPTIO UNKNOWN_EMP_ID;
END
SUSPEND;
END

Pernyataan SQL yang diambil dari TQuerry dengan menggunakan stored procedure ini akan menjadi:
EXECUTE PROCEDURE ADD_EMP_PROJ (20, “GUIDE”)

Menjalankan aksi stored procedure dengan TstoredProc
Untuk mengambil nilai inidividu dari keluaran parameter stored procedure menggunakan komponen TstoredProc:
1. Instantiate sebuah komponen prosedur penyimpanan.
2. Dalam properti StoredProcName, khususkan nama dari stored procedure.
3. Jika stored procedure memerlukan parameter masukan, masukan nilai untuk parameter menggunakan properti Params ata metoda ParamByName.
4. memohon metoda ExecProc.
Sebagai contoh, prosedur InterBase yang disimpan ADD_EMP_PROJ, dibawah, masukan baris baru untuk table EMPLOYEE_PROJECT. Tidak ada dataset yang dikempbalikan dan tidak ada nilai individu yang dikeblaikan dari parameter keluaran.
CREATE PROCEDUREADD_EMP_PROJ (EMP_NO SMALLINT, PROJ_ID CHAR (5))
AS
BEGIN
BEGIN
INSERT INTO EMPLOYEE_PROJECT (EMP_NO, PROJ_ID)
VALUES (:EMP_NO, :PROJ_ID);
WHEN SQLCODE –530 DO
EXCEPTION UNKNOWN_EMP_ID;
END
SUSPEND;
END
Kode Delphi untuk menjalankan stored procedure ADD_EMP_PROJ adalah :
With storedProc1 do begin
StoredProcNa,e := ‘ADD_EMP_PROJ’;
ExecProc;
end;

Memahami parameter prosedur yang di simpan
Ada empat macam tipe parameter yang bias diasosiasikan dengan prosedur yang di simpan:
• Parameter masukan, digunakan sebagai nilai yang diinput (dimasukan) ke stored procedure untuk pemrosesan.
• Parameter keluaran, digunakan oleh stored procedure untuk mengembalikan input ke aplikasi
• Parameter masukan/keluaran, digunakan sebagai nilai yang diinput (dimasukan) ke stored procedure untuk pemrosesan dan digunakan oleh stored procedure untuk mengembalikan input ke aplikasi.
• Hasil dari parameter, digunakan oleh beberapa stored procedure untuk mengembalikan kesalahan atau nilai status ke aplikasi. Prosedur yang di simpan hanya dapat dikembalikan oleh satu hasil parameter.
Meskipun stored procedure menggunakan tipe khusus, parameter bergantung dari penggunaan bahasa standar dari stored procedure pada server databasemu dan pada stored procedure secara spsifik. Sebagai contoh, prosedur individu yang disimpan pada server mana saja dapat diimplementasikan menggunakan parameter masukan, atau tidak menggunakan parameter. Di lain hal, beberapa orang menggunakan parameter server-specific. Sebagai contoh pada MS-SQL Server dan Sybase, stored procedure tidak pernah dikempablikan sebagai hasil dari parameter.

Akses ke parameter stored procedure disediakan oleh Tparam di dalam property TstoredProc.Params. jika nama stored procedure dikenali pada disain waktu dalam property StoredProcName, maka Tparam secara otomatis akan membuat masing-masing parameter dan memsaukannnya ke property dari Tparam. Jika nama stored procedure tidak ditemukan sampai batai waktu, maka Tparam perlu di program saat itu juga. Stored procedure tidak secara khusus dan manual membuat TParam memasukan komponen TStored yang single untuk digunakan dengan nomor mana saja yang tersedia pada stored procedure.

Catatan : Beberapa stored procedure mengembalikan dataset dengan tujuan ontuk mengeluarkan dan menghasilkan parameter. Aplikasi dapat menampilkan record dataset dalam [data-aware control], tapi dalam proses keluaran secara terpisah dan menghasilkan parameter. Sebagai informasi tambahan dalam menampilkan record dalam [data-aware control], lihat “Penggunaan stored procedure yang mengembalikan hasil “.

Menggunakan parameter masukan
Aplikasi menggunakan parameter masukan untuk memasukan nilai data untuk stored procedure. Seperti nilai yang digunakan dalam pernyataan SQL yang berkaitan dengan stored procedure, seperti membandingkan nilai untuk WHERE. Jika stored procedure mencakup parameter masukan, tandai nilai ke parameter sebelum menjalankan stored procedure.
Jika stored procedure mengembalikan dataset dan digunakan melalui query SELECT dalam komponen Tquery, masukan nilai parameter masukan sebagai daftar comma separated, dalam kurung, mengikuti nama stored procedure. Sebagai contoh, untuk pernyataan SQL dibawah mendapat data dari stored procedure yang dinamai GET_EMPPROJ dan masukan nilai parameter masukan = 52.

SELECT PROJ_ID
FROM GET_EMP_PROJ (52)

Jika stored procedure dijalankan dengan komponen TstoredProc, gunakan property Param atau metoda ParamByName untuk menyusun masing-masing parameter. Gunakan Properti Tparam yang sesuai untuk tipe data parameter, seperti property Tparam.AsString untuk parameter tipe CHAR. Susun nilai parameter masukan sebelum menjalankan atau mengaktifkan komponen TstoredProc. Sebagai contoh dibawah, parameter EMP_NO (tipe SMALLINT) unutk stored procedure GET_EMP_PROJ yang ditandai dengan nilai 52

with StoredProc1 do begin
ParamByName (‘EMP_NO’). AsSmallInt :=52;
ExecProc;
End;

Menggunakan parameter keluaran

Stored procedure menggunakan parameter keluaran untuk memasukan nilai [singleton data] ke aplikasi yang biasa disebut stored procedure. Parameter keluaran tidak ditandai dengan nilai kecuali oleh stored procedure dan hanya setelah stored procedure telah dijalankan. Periksa parametr keluaran dari aplikasi untuk mengambil nilainya setelah [invoking]metoda TstoredProc.ExecProc.
Gunakan property TstoredProc.Params atau metoda TStoredProc.ParamByName unutk mereferensi objek TParam yang menghasilakn parameter dan periksa hasilnya. Sebagai cotoh, untuk mengambil nilai dari parameter dan memasukannya kedalam property Text dari komponen Tedit.

with StoredProc1 do begin
ExecProc;
Edit.Text := Params [0].AsString;
End;
Kebanykan stored procedure mengembalikan parameter keluaran satu persatu, paramter keluaran dapat menghasilkan nilai [the sole return] untuk stored procedure yang juga tidak mengembalikan dataset, mereka dapat menghasilkan satu set nilai yang dikembalikan oleh prosedur yang juga dikempalikan oleh dataset, atau mereka menghasilkan nilai yang tidak punya hubungan langsung dengan record individu dalam data set yang dikempalikan oleh stored procedure. Masing-masing server mengimplementasikan stored procedure [differs in this regards].

Catatan :Sumber kode untuk stored procedure yang Informix dapat mempengaruhi pengembalian parameter keluaran walaupun kamu tidak melihat informasi parameter keluaran dalam editor StoredProc Parameter. Informix menterjemahkan parameter ke rekord dataset yang single yang dapat ditampilkan dalam aplikasi [data-aware control] mu.

Menggunakan parameter masukan / keluaran
Parameter masukan/keluaran masing masing mepunya fungsi yang dapat memasukan dan mengeluarkan parameter secara individual. Aplikasi dapat menggunakan parameter masuka /keluaran untuk memasukan nilai [singleton data] untuk stored procedure, yang dalam [turn reuses] parameter masukan/keluaran untuk memasukan nilai[singleton data] untuk memanggil aplikasi. Berkaitan dengan paramter masukan nilai unutk parameter maskan/keluaran haru disusun sebelum nilai unutk parameter masukan/keluaran akan tidak tersedia sampai sesudah stored procedure dijalankan.

Dalam contoh Oracle stored procedure dibawah, Parameter IN_OUTVAR adala parameter masukan/keluaran.
CREATE OR REPLACE PROCEDURE UPDATE_THE_TABLE (IN_OUTVAR IN OUT INTEGER)
AS
BEGIN
UPDATE ALLTYPETABLE
SET NUMBER82FLD = IN_OUTVAR
WHERE KEYFIELD = 0;
IN_OUTVAR:=1;
END UPDATE_THE_TABLE;

Dalam pemograman Delphi dibawah, IN_OUTVAR ditandai sebagi nilai masukan, stored procedure dijalankan kemudian nilai dalam IN_OUTVAR diperiksa dan disimpan ke memori variable.
with StoreProc1 do begin
ParamByName (‘IN_OUTVAR’).AsInteger := 103;
ExecProc;
IntergerVar := ParamByName(‘In_OUTVAR’).AsInteger;
end;

Menggunakan hasil dari parameter
Dalam rangka mengembalikan parameter keluaran dan dataset, beberapa stored procedure juga mengembalikan parameter hasil yang single. Hasil dari parameter biasanya digunakan untuk mengindikasi status kesalahan atau jumlah nomor dari rekord yang bedasarkan proses store procedure. Lihat dokementasi server datamabasemu untuk (determine) bila dan bagaimana cara server mendukung hasil dari parameter. Hasil dari parameter bukan berupa nilai kecuali oleh store procedure dan hanya jika store procedure sudah dijalankan. Mengingat hasil strore procedure dari aplikasi untuk mengambil nilainya setelah melihat pada metoda TStoredProc.ExecProc.
Gunakan property TstoredProc.Params atau metoda TstoredProc.ParamByName untuk mereferensi objek Tparam yang menunujukan hasil dari parameter dan memeriksa nilainya.
Datever := StoredProc1.ParamByName (‘MyOutputParam’).AsDate;

Mengakses parameter pada waktu perencanaan
Bila kamu terhubung unutk memindahkan serever database dengan menyeting DatabeseName dan propeti StoredProcName pada waktu perencanaan, maka kamu dapat menggungakan editor StoredProcParamter untuk menampilakan nama dan tipe datat dari masing-masing masukan parameter, kemudian kamu dapat menyusun nilai untuk masukan parameter untuk dimasukan ke server saat kamu menjalankan stored procedure.

Penting : jangan mengganti nama atau tipe data untuk masukan parameter berdasarkan dari server, atau saat kamu menjalankan stored procedure dengan perkecualian itu sudah dinaikan.

Beberapa server, sebagai contoh :Informix, jangan melaporkan nama atau tipe data. Dalam kasus ini , gunakan SQL Explorer atau Server vendor-supplied utilities unutk melihat pada sumber kode dari stored procedure pada server untuk[determine] parameter masukan dan type data. Lihat SQL explorer online help untuk informasi tambahan.

Pada waktu perencanaan, bila kamu tidak menerima daftar parameter dari stored procedure dari server yang berhubungan ( sebagai contoh bila kamu sedang tidak terhubung dengan server ), kemudian kamu harus meminta pada StroredProc Parameter editor, daftar masing-masing termasuk parameter masukan dan tandai masing-maisng tipe data dan nilainya. Untuk informasi tambahan gunakan StoredProc Parameters unutk membuat parameter, lihat “Setting parameter information at design time”.

Menyusun parameter informasi pada waktu perencanaan
Kamu dapat meminta dari kumpulan StoredProc parameter editor pada waktu perencanaan unutk menyusun parameter dan nilainya.
Kumpulan parameter editor memudahkankan mu menyusun stored procedure parameter. Jika kamu menyusun DatabaseName dan property StoredProcName dari komponen TstoredProc pada waktu perencanaan, maka semua parameter yang muncul akan di urutkan di kumpulan editor. Jika kamu tidak menyusun kedua paramter ini , maka tidak ada satu parameter pun yang akan diurutkan dan kamu harus memasukan merekan secara manual. Biasanya, beberapa tipe database tidak mengembalikan semua informasi parameter, seperti tipe. Unutk system database ini, gunakan SQL explorer utility untuk memerikasa strode procedure, menentukan tipe, kemudian menebak parameter dari kumpulan editor dan Object Inspector. Langkah-langkah untuk menyusun parameter stored procedure pada waktu perencanaan adalah :
1. Susun DatabaseName dan property StoredProcName.
2. Di Object Inspector , minta pada kumpulan parameter editor dengan meng kilik pada tombol di lembar Param.
3. Jika DatabaseName dan property StoredProcName belum disusun, tidak ada parameter yang akan muncul pada kumpulan editor. Secara manual masukan [arti] dari parameter dengan mengklik kanan yang berhubungan dengan kumpulan editor dan pilih Add dari menu.
4. pilih parameter satu – satu pada kumpulan editor untuk menampilkan property di Object Inspector.
5. jika tipe tidak secara otomatis menentukan propeti dari ParamType, pilih tipe paramter ( Input, Output, Input/Output atau Result ) dari daftar property drop-down.
6. jika tipe tidak secara otomatis menentukan properti dari Datatype, pilih tipe data dari daftar property drop-down. (untuk[mengembalikan]hasil susun dari Oracle stored procedure, susun tipe ke Cursor )
7. gunakan nilai property menentukan nilai awal unutk parameter masukan atau parameter masukan/keluaran.

Klik kanan pada kumpulan parameter editor unutk meminta konteks menu untuk mengoperasikan pada [arti] parameter. Tergantung, apakah ada parameter yang tersusun atau terseleksi, [enabled option include], masukan paramter baru, hapus parameter yang sudah ada, pindahkan parameter atas dan bawa dalam daftar dan pilih semua parameter yang sudah tersusun.
Kamu dapat mengedit arti dari semua TParam yang kamu tambahkan, tapi atribut dari objek TParam yang kamu tambahkan harus sesuai dengan atribut dari parameter untuk stored procedure pada server. Untuk mengedit TParam untuk parameter, pilih pada kumpulan parameter editor dan edit nilai proertinya di Object Inspector.

Catatan : Sybase, MS-SQL dan Informix tidak mengembalikan informasi tipe parameter, gunakan SQL Explorer untuk menentukan informasi ini.
Catatan : Informix tidak mengembalikan informasi tipe data. Gunakan QSL Explore untuk menentukan informasi ini.
Catatan : kamu tidak akan pernah dapat menyusun nilai unutk parameter masukan dan parameter hasil yang nilainya disusun bedasarkan stored procedure yang dijalakankan.

Membuat parameter saat dijalankan (runtime)
Jika nama dari stored procedure tidak dikenali dalam StoredProcName sampai runtime, maka tidak ada objek Tparam yang secara otomatis terbentuk unutk parameter dan mereka harus dibuat dengan program. Hal ini dapat dibuat dengan mengggunakan metoda TParam.Create atau metoda TParams.AddParam.

Sebagai contoh InterBase stored procedure GET_EMP_PROJ, dibawah, mencakup satu parameter masukan (EMP_NO) dan satu paramter keluaran (PROJ_ID).

CREATE PROCEDURE GET_EMP_PROJ (EMP_NO SMALLINT)
RETURNS (PROJ_ID CHAR(5))
AS
BEGIN
FOR SELECT PROJ_ID
FROM EMPLOYEE_PROJECT
WHERE EMP_NO = :EMP_NO
INTO :PROJ_ID
DO
SUSPEND;
END

Kode Delphi untuk mengasosiasikan stored procedure dengan TStored Proc dinamakan StoredProc1 dan membuat objek TParam untuk dua parameter menggunakan metoda TParam.Create.
Var
P1, P2: Tparam;
Begin

with StoredProc1 do begin
StoredProcName := ‘GET_EMP_PROJ’;
Params.Clear;
P1 :=TParam.Create (Params, ptInput);
P2 :=Tparam.Create (Params, ptOutput);
Try
Params[0].Name := ‘EMP_NO’;
Params[1].Name := ‘POJ_ID’;
ParamByName (‘EMP_NO’).AsSmallInt := 52;
ExecProc;
Edit1.Text := ParamByName (‘PROJ_ID’).AsString;
Finally
P1.Free;
P2.Free;
End;
End;

end;

Menjilid parameter

Saat kamu mempersiapkan dan menjalankan stored procedure, parameter masukan secara otomatis pindah ke paramter di server.
Gunakan property ParamBindMode untuk mengenali bagaimana parameter dalm komponen stored proecedure seharusnya dipindahkan ke parameter di server. Dengan kegagalan ParamBindMode yang disusun ke pbNyName, berarti parameter dari komponen stored procedure sesuai dengan server bedasarkan nama. Ini merupakan metode paling mudah untuk menjilid parameter.
Beberapa server juga mendukung menjilid parameter dengan mengurutkan nilainya, bila parameter muncul di store procedure. Dalam kasus ini mengenali parameter dalam kumpulan parameter itu penting. Parameter pertama yang kamu kenali, sesuai dangan parameter masukan di server, parameter kedua sesuai dangan parameter masukan yang kedua di server, dan seterusnya. Juka servermu di dukung dengan parameter yang dijilid sesuai dengan nilai urutnya, kamu dapat menyusun ParamBindMode ke pbByNumber.

Tip : jika kamu ingin menyusun ParamBindMode ke pbByNumber, kemu perlu mengenali parameter yang benar dengan perintah yang benar. Kamu dapat menampilkan server sumber kode store procedure di SQL Explorer untuk menentukan perintah yang benar dan tipe parameter.

Menampilkan parameter informasi pada waktu perencanaan
Jika kamu punya hubungan [acces] ke database server pada waktu perencanaan, terdapat dua cara untuk menampilakn informasi tentang parameter yang digunakan oleh store procedure:
• minta pada SQLExplorer untuk menampilkan sumber kode untuk store procedure pda sumber tertentu. Sumber kode termasuk penyataan parameter yang dapat mengenali tipe data dan nama unutk masing-masing parameter.
• Gunakan Ooject Inspector untuk menampilkan property setting untuk objek TParam yang individual.
Kamu dapat menggunakan SQL Explorer unutk memerikasa store procedure pda server databasemu jika kamu menggunkan driver BDE. Jika kamu menggunakan driver ODBC kamu tidak dapat memeriksa strored procedure menggunkan SQL Explorer. Sementara bila menggunakan SQL Explorer bukan merupakan suatu pilihan, kdangan-kadang SQL Explorer memberikan lebih banyak inforasi dibandingkan Object Inspector yang menampilkan objek Tparam. Jumlah informasi yang diberikan tentang stored procedure di Object Inspector tergantung pada server databasemu.

Untuk menampilkan definisi parameter di Object Inspector :
1. pilih komponen stored procedure
2. susun property database dari komponen stored procedure ke BDE untuk nama lain server databasemu (atau property DatabaseName dari Tdatabase).
3. susun property StoredProcName ke nama dari stored procedure
4. klik pada tombol ellipsis di property TstoredProc.Params di Object Inspector.
5. pilih paramter individu di kumpulan editor untuk menampilkan property setting di Object Inspector.

Untuk beberapa server semua informasi parameter mungkin tidak bisa diperoleh/didapat.
Di Object Inspector , saat menampilkan objek Tparam yang individual, property TparamType ditunjukan bila parameter yang sudah dipilih sebagai parameter masukan, masukan keluaran, keluran atau hasil dari parameter. Property Data Type ditunjukan oleh tipe data dari nilai parameter seperti string, integer atau date. Nilai dari edit box tidak memperbolehkanmu untuk memasukan nilai untuk parameter masukan yang sudah dipilih.

Catatan : Sybase, MS-SQL dan Informix tidak memberikan informasi tipe parameter. Gunakan SQL Explorer atau sever verdor_supplied untuk menunjukan informasi ini.

Catatan : Informix tidak memberikan informasi tipe data. Gunakan SQL Explorer server vendor supplied untuk menunjukan informasi ini.

Keterangan lebih lanjut tentang nilai parameter lihat di “ menyeting informasi parameter pada waktu perencanaan”

Catatan : kamu tidak bias menyusun nilai untuk parameter keluaran dan hasil parameter. Parameter tipe ini sudah memiliki nilai yang dikeluarkan oleh stored procedure.

Bekerja dengan Oracle [overloaded] stored procedures
Server Oracle memperbolehkan stored procedure yang kelebihan kapasitas, procedure yang kelebihan kapasitas berbeda dengan procedure dengan nama yang sama. Komponen dari stored procedure yaitu property Overload tidak memungkinkan sebuah aplikasi untuk mengenali procedure saat dijalankan.
Jika kelebihan nya nol, maka diasumsikan belum kelebihan kapasitas. Tapi jika kelebihannya 1 maka komponen stored procedures yang dijalankan adalah stored procedure pertama yang ditemukan dan server Oracle akan mempunyai nama yang kelebihan kapasitas. Jika kelebihan 2 maka akan menjalankan yang kedua dan seterusnya.

Catatan :stored procedure yang kelebihan muatan mungkin memiliki parameter masukan dan keluaran yang berbeda. Lihat di dokumentasi server Oracle untuk informasi tambahan.

Query Analyzer offers a quick and dirty method for performing queries against any of your SQL Server databases. It’s a great way to quickly pull information out of a database in response to a user request, test queries before implementing them in other applications, create/modify stored procedures and execute administrative tasks.
SQL Profiler provides a window into the inner workings of your database. You can monitor many different event types and observe database performance in real time. SQL Profiler allows you to capture and replay system “traces” that log various activities. It’s a great tool for optimizing databases with performance issues or troubleshooting particular problems.
Service Manager is used to control the MSSQLServer (the main SQL Server process), MSDTC (Microsoft Distributed Transaction Coordinator) and SQLServerAgent processes. An icon for this service normally resides in the system tray of machines running SQL Server. You can use Service Manager to start, stop or pause any one of these services.
Data Transformation Services (DTS) provide an extremely flexible method for importing and exporting data between a Microsoft SQL Server installation and a large variety of other formats. The most commonly used DTS application is the “Import and Export Data” wizard found in the SQL Server program group.
Books Online is an often overlooked resource provided with SQL Server that contains answers to a variety of administrative, development and installation issues. It’s a great resource to consult before turning to the Internet or technical support.
Hopefully, this article has provided you with a brief introduction to the various tools available to Microsoft SQL Server users. Now get out there and give them a whirl!

LEARN HOW TO ADMINISTER USER RIGHTS

Administrators can assign users or groups special user rights that allow them to perform specific actions, such as backing up files, restoringfiles, or logging on to a system.

User rights and permissions aren’t synonymous. Permissions apply to
objects, while user rights apply to users and have system-wide effect. Forexample, Read permission on a file allows specified users to read thatfile, and the Log On Locally user right allows specified users to log on tothe system.

You can administer user rights through the User Manager application.
Here’s how:

1. Run User Manager from the Administrative Tools folder.

2. Click User Rights from the Policies menu.

3. In the Right drop-down box, select a user right. The Grant To box
underneath will list all the users or groups who have been assigned thisright.

4. Choose the Add or Remove button to grant or revoke a user right for aspecific user or group.

By default, not all user rights are shown in the drop-down box. To
display them all, check Show Advanced User Rights.

SQL Fundamentals

Part 1: Introduction
The Structured Query Language (SQL) comprises one of the fundamental building blocks of modern database architecture. SQL defines the methods used to create and manipulate relational databases on all major platforms. At first glance, the language may seem intimidating and complex but it’s really not all that bad. In a series of articles over the next few weeks we’ll explore the inner workings of SQL together. By the time we’re through, you’ll have the fundamental knowledge you need to go out there and start working with databases!
This week, our first article in the SQL series provides an introduction to the basic concepts behind SQL and we’ll take a brief look at some of the main commands used to create and modify databases. Throughout this article, please keep our goal in mind: we’re trying to get the “big picture” of SQL — not a mastery of the individual commands. We’ll provide a few examples for illustrative purposes and explain the theory behind them, but don’t feel frustrated if you can’t write your own SQL commands after reading this article. We’ll cover each of the major commands in detail in future weekly installments.
By the way, the correct pronunciation of SQL is a contentious issue within the database community. In their SQL standard, the American National Standards Institute declared that the official pronunciation is “es queue el.” However, many database professionals have taken to the slang pronunciation “sequel.” The choice is yours.
SQL comes in many flavors. Oracle databases utilize their proprietary PL/SQL. Microsoft SQL Server makes use of Transact-SQL. However, all of these variations are based upon the industry standard ANSI SQL. In our tutorial series, we’ll stick to ANSI-compliant SQL commands that will work on any modern relational database system.
SQL commands can be divided into two main sublanguages. The Data Definition Language (DDL) contains the commands used to create and destroy databases and database objects. After the database structure is defined with DDL, database administrators and users can utilize the Data Manipulation Language to insert, retrieve and modify the data contained within it. In the next two sections of this article, we’ll explore DDL and DML in further detail. In future articles we’ll take an in-depth look at specific SQL commands.
Part 2: Data Definition Language

The Data Definition Language (DDL) is used to create and destroy databases and database objects. These commands will primarily be used by database administrators during the setup and removal phases of a database project. Let’s take a look at the structure and usage of four basic DDL commands:
CREATE

Installing a database management system (DBMS) on a computer allows you to create and manage many independent databases. For example, you may want to maintain a database of customer contacts for your sales department and a personnel database for your HR department. The CREATE command can be used to establish each of these databases on your platform. For example, the command:
CREATE DATABASE employees
creates an empty database named “employees” on your DBMS. After creating the database, your next step is to create tables that will contain data. (If this doesn’t make sense, you might want to read the article Microsoft Access Fundamentals for an overview of tables and databases.) Another variant of the CREATE command can be used for this purpose. The command:
CREATE TABLE personal_info
(first_name char(20) not null, last_name char(20) not null, employee_id int not null)
establishes a table titled “personal_info” in the current database. In our example, the table contains three attributes: first_name, last_name and employee_id. Don’t worry about the other information included in the command — we’ll cover that in a future article.
USE
The USE command allows you to specify the database you wish to work with within your DBMS. For example, if we’re currently working in the sales database and want to issue some commands that will affect the employees database, we would preface them with the following SQL command:
USE employees
It’s important to always be conscious of the database you are working in before issuing SQL commands that manipulate data.
ALTER
Once you’ve created a table within a database, you may wish to modify the definition of it. The ALTER command allows you to make changes to the structure of a table without deleting and recreating it. Take a look at the following command:
ALTER TABLE personal_info
ADD salary money null
This example adds a new attribute to the personal_info table — an employee’s salary. The “money” argument specifies that an employee’s salary will be stored using a dollars and cents format. Finally, the “null” keyword tells the database that it’s OK for this field to contain no value for any given employee.
DROP
The final command of the Data Definition Language, DROP, allows us to remove entire database objects from our DBMS. For example, if we want to permanently remove the personal_info table that we created, we’d use the following command:
DROP TABLE personal_info
Similarly, the command below would be used to remove the entire employees database:

DROP DATABASE employees
Use this command with care! Remember that the DROP command removes entire data structures from your database. If you want to remove individual records, use the DELETE command of the Data Manipulation Language.
That’s the Data Definition Language in a nutshell. In the next section of this article, we’ll take a look at how the Data Manipulation Language is used to manipulate the information contained within a database.
The Data Manipulation Language (DML) is used to retrieve, insert and modify database information. These commands will be used by all database users during the routine operation of the database. Let’s take a brief look at the basic DML commands:
INSERT
The INSERT command in SQL is used to add records to an existing table. Returning to the personal_info example from the previous section, let’s imagine that our HR department needs to add a new employee to their database. They could use a command similar to the one shown below:
INSERT INTO personal_info values(‘bart’,’simpson’,12345,$45000)
Note that there are four values specified for the record. These correspond to the table attributes in the order they were defined: first_name, last_name, employee_id, and salary.
SELECT
The SELECT command is the most commonly used command in SQL. It allows database users to retrieve the specific information they desire from an operational database. Let’s take a look at a few examples, again using the personal_info table from our employees database.
The command shown below retrieves all of the information contained within the personal_info table. Note that the asterisk is used as a wildcard in SQL. This literally means “Select everything from the personal_info table.”
SELECT *
FROM personal_info
Alternatively, users may want to limit the attributes that are retrieved from the database. For example, the Human Resources department may require a list of the last names of all employees in the company. The following SQL command would retrieve only that information:
SELECT last_name
FROM personal_info
Finally, the WHERE clause can be used to limit the records that are retrieved to those that meet specified criteria. The CEO might be interested in reviewing the personnel records of all highly paid employees. The following command retrieves all of the data contained within personal_info for records that have a salary value greater than $50,000:
SELECT *
FROM personal_info
WHERE salary > $50000
UPDATE
The UPDATE command can be used to modify information contained within a table, either in bulk or individually. Each year, our company gives all employees a 3% cost-of-living increase in their salary. The following SQL command could be used to quickly apply this to all of the employees stored in the database:
UPDATE personal_info
SET salary = salary * 1.03
On the other hand, our new employee Bart Simpson has demonstrated performance above and beyond the call of duty. Management wishes to recognize his stellar accomplishments with a $5,000 raise. The WHERE clause could be used to single out Bart for this raise:
UPDATE personal_info
SET salary = salary + $5000
WHERE employee_id = 12345
DELETE
Finally, let’s take a look at the DELETE command. You’ll find that the syntax of this command is similar to that of the other DML commands. Unfortunately, our latest corporate earnings report didn’t quite meet expectations and poor Bart has been laid off. The DELETE command with a WHERE clause can be used to remove his record from the personal_info table:
DELETE FROM personal_info
WHERE employee_id = 12345

Transaksi dan “Cache updated”

Ketika sebuah transaksi sedang aktif, pembaharuan (update) secara seketika dikirimkan ke tabel yang bersesuaian. Kesalahan (error, seperti “integrity constraint” dan lain-lain ) secara langsung dilaporkan ke clients. Karena pembaharuan secara seketika dikirimkan ke tabel yang bersesuaian, maka pembaharuan tersebut dapat dilihat oleh transaksi yang lain. Dan karena setiap record yang sedang diubah kemudian dikunci (locked), maka pengguna lain tidak dapat mengganggu.

Kelakuan ini berbeda dari lapisan penyangga pembaharuan (cached updates layer, seperti batch atau burst updates), dimana pembaharuan tidak langsung dikirimkan ke tabel yang bersesuaian sampai waktu “commit”. Berarti tidak ada pesan kesalahan yang dilaporkan sampai waktu “commit”. Juga tidak ada record yang dikunci (lock) sampai pengguna memutuskan untuk melakukan “commit” terhadap pembaharuan (updates). Pengucian (locks) tetap dijaga hanya selama proses “commit”. Jika kesalahan (error) terjadi selama proses “commit”, client diberikan pilihan untuk membatalkan proses “commit”. Jika client membatalkan abort sebuah proses commit, kondisi awal dari tabel akan dipulihkan.

Keuntungan utama dari fitur “cached updates” adalah penguncian hanya dilakukan selama waktu commit, oleh karena itu kenaikan waktu akses dari SQL server untuk transaksi sistem lain. Penghentian penguncian transaksi pengguna lain saat record diubah, dan transaksi lokal membatasi pengguna untuk mengubah hanya jika jumlah maksimum record yang dapat dikunci. “Cached updates” menghindari masalah ini, tetapi mengijinkan pengguna lain untuk mengubah data di bawah pengawasan anda. Perbedaan-perbedaan ini dirangkum dalam tabel berikut ini :

Keuntungan Kerugian
Transaksi Pembaharuan seketika dikirimkan ke tabel Penghentian penguncian pengguna lain ketika sebuah record diubah
Perubahan record seketika terlihat oleh pengguna lain.

Record-record yang sedang diubah akan dikunci. Transaksi lokal membatasi pengguna untuk melakukan perubahan hanya jumlah maksimum record yang dapat dikunci
Kesalahan seketika dilaporkan
Cached updates Penguncian dilakukan selama waktu commit, kenaikan waktu akses server untuk transaksi lain Mengijinkan pengguna lain untuk mengubah record yang sedang anda gunakan tanpa menyadarinya
cached updates dapat digunakan dengan cursor manapun pada sebuah tabel tunggal Jika kesalahan terjadi selama proses commit, anda dapat membatalkannya, mengembalikan tabel ke kondisi awal, semua perubahan dihilangkan
Tidak ada pembatasan maksimum penguncian untuk dBase (100) dan Paradox (255) selama proses pengubahan. Ketika melakukan commit lebih dari maksimum, maka sebuah kunci eksklusif (exclusive lock) pada tabel akan dibutuhkan untuk melakukan commit.

Cached updates
Fitur “cached update” memungkinkan pengguna untuk mengambil data (retrieve data) dari basisdata dan melakukan perubahan terhadap “temporarily cached data” tanpa secara langsung menuliskan nilai aktual ke basisdata yang bersesuaian. Pengguna dapat membuat perubahan untuk periode yang lama dengan jumlah penguncian sumberdaya minimum terhadap basisdata aktual. Setelah melakukan perubahan terhadap data, pengguna memanggil (call) fungsi pembaharuan (update function) untuk menyimpan (save) perubahan-perubahan di dalam basisdata aktual. Fungsi pembaharuan (update function) mengirim (send) ke basisdata sekumpulan (batch) dari keseluruhan penyisipan (insert), penghapusan (delete), dan perubahan (modification) yang telah dibuat sejak pemanggilan fungsi pembaharuan (update function call) terakhir kali.

Untuk mendukung fitur (cached update), sebuah lapisan kursor spesial (special cursor layer) diinstalasi di atas setiap kursor. Implementasi dan penggunaan fitur “cached update” akan dijelaskan pada sub bab berikut.

Dataset.Cacheupdate
Menspesifikasikan apakah “cached update” diaktifkan (enable) untuk dataset.

property CachedUpdates: Boolean;

Deskripsi
CachedUpdates aktif (enable) atau tidak aktif (disable) untuk menggunakan “cached update” pada dataset. Jika “CachedUpdates” bernilai True, maka “cached updates” adalah aktif (enabled). Jika “CachedUpdates” bernilai False, maka “cached updates” adalah tidak aktif (disabled).

Ketika “cached updates” aktif (enabled), maka pembaharuan (updates) ke sebuah dataset (seperti perubahan posting, penyisipan record-record baru, atau penghapusan record), akan disimpan dalam “internal cache” pada mesin client daripada dituliskan secara langsung ke tabel basisdata yang bersesuian. Ketika perubahan selesai, maka program aplikasi akan menuliskan keseluruhan perubahan “cache” ke basisdata dalam konteks transaksi tunggal.

“Cached updates” adalah paling berguna ke aplikasi client dalam aplikasi “two-tiered”. Keuntungan utama dari kemampuan “cached update” adalah :
– Transaksi lebih sedikit dan waktu transaksi lebih singkat.
– Pengurangan beban jaringan (network traffic).

Kelemahan potensial dari kemampuan “cached updates” adalah :
Aplikasi lain dapat mengakses dan mengubah data aktual pada server sementara pengguna melakukan “editing local copies” dari data, maka berakibat dalam konflik pembaharuan (update conflict) ketika “cached updates” diaplikasikan ke basisdata.
Aplikasi lain tidak dapat mengakses perubahan data yang dilakukan program aplikasi sampai “cached updates” diaplikasikan ke basisdata.

Catatan : Selain penggunaan “cached updates”, aplikasi dapat memperoleh keuntungan yang sama dengan pengendalian yang lebih besar dengan menggunakan “client dataset” dan “provider component”.
Catatan: Ketika “cached updates” diaktifkan (enable), perubahan data disimpan di dalam memory lokal. Media penyimpanan adalah format Paradox dalam tabel memori. Ini berakibat pada aplikasi yang berjalan (run) dalam sebuah lingkungan jaringan (network) sehingga parameter NET DIR untuk driver Borland Database Engine (BDE) untuk Paradox harus di-set, meskipun aplikasi mungkin dirancang untuk menggunakan tipe basisdata yang lain. Kesalahan akibat penentuan parameter ini dapat berakibat pada “EDBEngineError exception”. Terdapat dua cara untuk menentukan NET DIR. Yang pertama dengan utilitas konfigurasi BDE dari BDE Administrator (dijelaskan dalam BDE Administrator online help). Cara yang kedua melalui properti TSession.NetFileDir .

ApplyUpdates
Menuliskan penundaan (pending) dataset cached update ke basisdata.

procedure ApplyUpdates;

Deskripsi

Pemanggilan (call) ApplyUpdates untuk menuliskan penundaan (dataset’s pending cached updates) ke basisdata. Metoda ini melewatkan “cached data” ke basisdata untuk penyimpanan, tetapi perubahan tidak dilakukan (committed) ke basisdata. Progam aplikasi harus secara eksplisit memanggil (call) komponen metoda “Commit” untuk menjalankan perubahan ke basisdata jika penulisan berhasil, atau memanggil (call) metoda “Rollback” untuk membatalkan jika terjadi kesalahan (error).

Mengikuti keberhasilan penulisan ke basisdata , dan keberhasilan pemanggilan (call) ke metode “Commit”, maka program aplikasi harus memanggil (call) metode CommitUpdates untuk menghapus “cached update buffer”.

Catatan: Metode yang lebih disarankan untuk pembaharuan dataset adalah memanggil (call) komponen metode ApplyUpdates terhadap basisdata daripada memanggil metode ApplyUpdates terhadap dataset secara individual. Komponen metode ApplyUpdates terhadap basisdata akan memelihara “committing” dan “rolling back” terhadap transaksi dan menghapus (cache) ketika operasi berhasil.
Prosedur berikut ini menggambarkan bagaimana mengaplikasikan “cached updates” dari dataset ke basisdata dengan respon penekanan sebuah tombol (button click):

procedure TForm1.ApplyButtonClick(Sender: TObject);

begin
with CustomerQuery do
begin
Database1.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
Database1.Commit; {on success, commit the changes};
except
Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;

end;

CommitUpdates
Menghapus penyangga cached update.

procedure CommitUpdates;

Deskripsi

Memanggil (call) CommitUpdates untuk menghapus “cached updates buffer” setelah keberhasilan pemanggilan (call) ke “ApplyUpdates” dan komponen metode “Commit” terhadap basisdata. Penghapusan “cache” setelah menerapkan pembaharuan (update) untuk memastikan bahwa “cache” sudah kosong kecuali untuk record yang tidak dapat diproses dan dilewati (skip) oleh “OnUpdateRecord” atau “OnUpdateError event handlers”. Program aplikasi dapat mencoba untuk melakukan perubahan terhadap record yang masih di dalam cache.

Pengubahan terhadap record yang dilakukan setelah pemanggilan (call) terhadap “CommitUpdates” akan mengumpulkan ulang “cached update buffer” dan membutuhkan “subsequent call” terhadap ApplyUpdates untuk memindahkannya ke basisdata.

Catatan: Program aplikasi yang menggunakan komponen metode ApplyUpdates untuk diaplikasikan dan menjalankan (commit) penundaan pembaharuan (pending updates) untuk seluruh dataset yang bersesuaian dengan komponen basisdata tidak perlu untuk memanggil (call) CommitUpdates.

RevertRecord
Mengembalikan record sekarang (current record) di dalam dataset untuk kondisi tidak diubah ketika “cached updates” diaktifkan (enable).

procedure RevertRecord;

Deskripsi

Memanggil RevertRecord untuk membatalkan perubahan yang dibuat record sekarang (current record) ketiak “cached updates” diaktifkan (enable).

Catatan: Untuk membatalkan semua perubahan untuk seluruh penundaan pembaharuan dalam cache, lakukan pemanggilan (call) CancelUpdates.

CancelUpdates
Menghapus (clear) keseluruhan penundaan (pending) “cached updates” dari cache dan mengembalikan (restore) dataset ke kondisi sebelumnya.

procedure CancelUpdates;

Deskripsi

Menghapus (clear) keseluruhan penundaan (pending) “cached updates” dari cache dan mengembalikan (restore) dataset ke kondisi ketika tabel telah dibuka, “cached updates” merupakan terakhir aktif (last enable) atau pembaharuan yang terakhir kali berhasil diaplikasikan ke basisdata.

Ketika dataset ditutup (close) atau properti CachedUpdates di-set menjadi False, maka CancelUpdates akan dipanggil secara otomatis.

Catatan: Untuk membatalkan perubahan ke record tunggal, lakukan pemanggilan (call) RevertRecord.

UpdatesPending
Mengindikasikan apakah “cached updates buffer” mengandung record yang belum diaplikasikan.

property UpdatesPending: Boolean;

Deskripsi

Menguji “UpdatesPending” untuk mengetahui status dari “cached updates buffer”. Jika UpdatesPending bernilai True, maka berarti sedang disunting (edited), dihapus (deleted), atau penyisipan record (inserted record) untuk diaplikasikan ke basisdata. Jika UpdatesPending bernilai False, maka tidak ada record di dalam cache.

Contoh berikut ini menerapkan “cached updates” dari relasi master/detail. Pembaharuan (update) diterapkan dari “BeforeClose event handler” terhadap detail set. Perlu dicatat bahwa penggunaan “cached updates” dalam kondisi ini membutuhkan anda untuk mengaplikasikan pembaharuan ssetiap saat anda mengubah record dari tabel. Untuk lebih mengendalikan “cached updates”, anda harus menggunakan juga client dataset.

procedure TForm1.DetailBeforeClose(DataSet: TDataSet);
begin
if Master.UpdatesPending or Detail.UpdatesPending then
if Master.UpdateStatus = usInserted then
Database1.ApplyUpdates([Master, Detail])
else
Database1.ApplyUpdates([Detail, Master]);
end;

UpdateStatus
Melaporkan status pembaharuan untuk record sekarang (current).

function UpdateStatus: TUpdateStatus;

Deskripsi

Pemanggilan (call) UpdateStatus untuk menentukan status pembaharuan (update status) untuk record sekarang (current record) dalam sebuah dataset ketika “cached updates” diaktifkan (enabled). Status pembaharuan dapat sering berubah ketika record disunting (edited), disisipkan (inserted), atau dihapus (deleted). UpdateStatus menawarkan sebuah metode yang meyakinkan untuk program aplikasi mengakses status sekarang (current status) sebelum menyelesaikan operasi yang bergantung pada status pembaharuan (update status) dari record individual pada dataset.

OnUpdateRecord
Terjadi ketika “cached updates” diaplikasikan ke sebuah record.

type TUpdateRecordEvent = procedure(DataSet: TDataSet; UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction) of object;
property OnUpdateRecord: TUpdateRecordEvent;

Deskripsi

Penulisan sebuah “OnUpdateRecord event handler” untuk memproses pembaharuan yang tidak dapat ditangani oleh komponen pembaharuan (update) tunggal, seperti implemensi dari “cascading update”, “insertion”, atau “deletion”. Fungsi “handler” juga berguna untuk aplikasi yang membutuhkan kendali tambahan atas substitusi parameter dalam komponen pembaharuan (update component).

DataSet adalah nama dari dataset yang akan diterapkan pembaharuan.

UpdateKind mengindikasikan apakah pembaharuan sekarang (current update) adalah penyisipan sebuah record, atau penghapusan sebuah record, atau penghapusan sebuah record.

UpdateAction mengindikasikan aksi yang dilakukan “OnUpdateRecord handler” sebelum terjadi. Pada masukan ke “handler”, UpdateAction selalu ditentukan bernilai Fail. Jika “OnUpdateRecord” berhasil, maka akan menentukan “UpdateAction” menjadi “Applied before exiting”.

Kode program dalam “OnUpdateRecord handler” harus memanggil metode apapun yang membuat perbedaan dengan record sekaang (current).

Catatan: Sebagai pendekatan alternatif, program aplikasi dapat menggunakan “client dataset” dan “provider component” untuk menangani “cached updates”. Alternatif ini menyediakan lebih banyak dukungan dan pengendalian yang lebih besar.

How to Search for Date and Time Values
Using Microsoft SQL Server 2000

by Bryan Syverson, author of Murach’s SQL for SQL Server

Suppose you’re writing a query to find all the invoices that were written on January 6, 2003. You know from the control totals that 122 invoices were written that day. But when you run this query:
SELECT * FROM Invoices
WHERE InvoiceDate = ‘2003-01-06’
the result set is empty. What’s going on?

How Dates and Times are Stored in SQL Server?
Before you can effectively query date/time (or temporal) data, you have to know something about how date/time values are stored. SQL Server supports two date/time data types: datetime and smalldatetime. The difference between the two is the amount of storage used. Datetime uses 8 bytes of storage, while smalldatetime uses only 4 bytes. For this reason, datetime can represent date/time values within a wider range and with more precision than smalldatetime. These differences are summarized in the table below.
Type Minimum Maximum Precision
datetime Jan 1, 1753
midnight Dec 31, 9999
23:59:59.997
(0.003 seconds until midnight) To the nearest
3.33 milliseconds
smalldatetime Jan 1, 1900
midnight Jun 6, 2079
23:59
(1 minute until midnight) To the nearest
minute
Both datetime and smalldatetime represent the date and time as a value that’s equal to the number of days in relationship to a base date. In SQL Server, that base date is midnight on January 1, 1900. As you can see in the table, the smalldatetime type can only represent dates from this base date on. In contrast, the datetime type can also represent dates that are before January 1, 1900. To do that, it stores those values as negative numbers.
To visualize how date/time values are stored, you can think of them as consisting of two parts. The integer portion represents the number of whole days since January 1, 1900. The fractional portion represents the fraction of a day that’s passed since midnight. For example, the date/time value representing noon on January 4, 1900 is stored as 3.5. In this case, 3 represents three full days since the base date and 0.5 represents one half of a day between midnight and noon. To see this, submit the following query:
Note: The CAST function explicitly changes the data type of a value as specified. So in this statement, the inner CAST changes the string literal ‘1900-01-04 12:00’ to a value of data type datetime. Then, the outer CAST changes that datetime value to a value of data type float. The final result is a floating-point representation of the datetime value that represents noon on January 4, 1900.
SELECT CAST(CAST(‘1900-01-04 12:00’ AS datetime) AS float)
So far, so good. But the problems that crop up in querying date/time data are caused by confusion over two fundamental facts that aren’t so obvious. First, date/time data types are approximate numerics, not exact numerics. Second, date/time data types can’t store a date without a time or a time without a date.
Date/Time Values are Approximate Numerics
Datetime and smalldatetime are like the floating-point data types, float and real, in that they’re approximate numerics. That means the value retrieved from SQL Server may be different from the value that was originally stored. For example, if you store the expression 10/3.0 in a column of data type float, you’ll retrieve a value 3.3333330000000001. Although this is a reasonable representation of ten thirds, it’s not exact since it’s rounded past the 6th digit. In fact, if you add three such values together, you get 9.9999990000000007, not 10. Of course, most programmers understand this as a rounding error. And it’s a persistent problem for all digital computers, not just those running SQL Server. Still, you need to be aware of it as you code search conditions.
In contrast, when working with exact numeric data, the value retrieved from SQL Server is exactly the value that was originally stored. For example, if you store 10/3.0 in a column of data type int, it’s stored as 3 and retrieved as 3. In this case, SQL Server implicitly casts the result of the expression as a real value, 3.333333. Then, SQL Server implicitly casts 3.333333 as an integer because it’s being stored in a column of type int. Although this is still a rounding error, it occurs before the value is stored, not as a result of the physical limitations of computer storage. In other words, the error was introduced by using the wrong data type, not by the inherent limitation of the data type itself. Since the system always returns the same value as was stored, the data type is exact.
Now, to see how this affects date/time values, consider the date and time value for 8:00AM on January 4, 1900. As you saw above, noon on this day is stored as 3.5, or halfway through the fourth day. In contrast, 8:00AM is one third of the way through the day, so its representation will be approximate. To see this for yourself, submit the following query:
SELECT CAST(CAST(‘1900-01-04 08:00’ AS datetime) AS float)
You’ll get the following result:
3.3333333333333335
But if you submit this query:
SELECT CAST(3.3333333 AS datetime), CAST(3.3333334 AS datetime)
you’ll get the following results:
1900-01-04 07:59:59.997 1900-01-04 08:00:00.003
As you can see, these three values are all quite close. In fact, they’re close enough to be considered 8:00AM for most applications. However, in a search condition based on a single value, such as:
WHERE (DTValue = ‘1900-01-04 08:00’)
you’d only match those rows where the stored value exactly matches 3.3333333333333335. You’ll see how to get around this later in this article.

Dates Without Times and Times Without Dates
SQL Server doesn’t provide data types for storing just the date or just the time. So if you store a date/time value without an explicit time, the fractional portion of the value is set to zero. This represents midnight as 00:00:00. Similarly, if you store a date/time value without an explicit date, the integer portion of the value is set to zero. This represents the date January 1, 1900. To see this, submit the following query:
SELECT CAST(‘1900-01-04′ AS datetime), CAST(’10:00’ AS datetime)
which returns the following result:
1900-01-04 00:00:00.000 1900-01-01 10:00:00.000
Whether you can ignore the date or the time component when you query a date/time column depends on how the column has been designed and used.

The Effect of Database Design on Querying
Database designers don’t always use date/time columns appropriately. At the time the database is designed, each date/time column should be identified as to whether it will store both dates and times, dates only, or times only. The designer, by using defaults, constraints, and triggers, can enforce these rules to prevent the accidental storage of data that are either unnecessary or not applicable.
For example, a column in an accounts payable system for the date an invoice is received is unlikely to need the time. In that case, the designer should plan to use the column solely for dates and never store the time component. A trigger could be assigned to prevent the non-integer portion of the date value from being stored when updating or inserting.
Generally, however, the programmer is forced to work with an existing database. In this case, you should examine the way in which the date/time values are being used before you assume the designer did his or her job correctly.
The simplest way to do that is to submit a query using a search condition similar to the following, where DT is the date/time column in question:
Note: The FLOOR function returns the largest integer that is less than or equal to the specified value. In this expression, FLOOR is applied to the floating-point representation of the DT column. This simply strips off the fractional portion of the number.
WHERE CAST(FLOOR(CAST(DT AS float))AS datetime) = 0 OR
DT – CAST(FLOOR(CAST(DT AS float))AS datetime) = 0
The first expression returns the date (integer) portion of the value, while the second returns the time portion. If this query returns no rows, it’s likely that the column has been used consistently to store both dates and times, since the date is never 0 and the time is never 0.
Keep in mind, of course, that if the above query returns rows, it doesn’t necessarily imply that the column has been used inconsistently. If the time happens to be exactly midnight or the date happens to be January 1, 1900, then it’ll show up in the result set. In that case, you can test for columns with time-only or date-only data by using either of these two queries:
WHERE TOnly Tonly – (CAST(FLOOR(CAST(TOnly AS float))AS datetime))
WHERE DOnly CAST(FLOOR(CAST(DOnly AS float))AS datetime)
Here, TOnly and DOnly are date/time columns that you expect contain only times or dates, respectively. If the query returns rows, then those rows don’t contain the type of data you expected.
Determining what kind of data are stored in the date/time columns of each table is important for intelligent querying. If the columns are used consistently, then your job is easier. However, even if the columns are used inconsistently, you’ll at least know which query pitfalls to watch out for as you code your queries.

Performance Considerations in Querying
A search based on an indexed column completes faster than a search based on a non-indexed column. So date/time columns that are searched frequently should be indexed. Be aware, though, that if you then use a function in the search condition, the index can’t be used in the same way, which slows performance. For searches that are executed thousands of times a day on a production database, this can cause significant performance problems. For this reason, you should avoid using functions in such search conditions whenever possible. As you’ll see in the examples that follow, this sometimes results in solutions that are less flexible than those that use functions.
In addition, keep in mind that some applications require that you search for portions of a date/time column. The portion could be date only, time only, or even a smaller portion, such as a year or hour. In that case, it may improve performance to split a single date/time column into two or more separate columns, and then index those that are searched most often.

How to Search by Date
Frequently. you’ll need to search a date/time column for a specific date, regardless of time. If the data in the column have been used consistently with the time component set to zero, that’s no problem. You just search for the date you’re looking for.
But consider the following table, called DateSample:
ID DateVal
— ———————–
1 2001-02-28 10:00:00.000
2 2002-02-28 13:58:32.823
3 2002-02-29 00:00:00.000
4 2002-02-28 00:00:00.000
As you can see, the DateVal column is used inconsistently. The third and fourth values indicate that the column might have been intended to store dates only, but the first two values indicate that this wasn’t enforced.
As a result, if you use the following query to retrieve rows with the date February 28, 2002:
SELECT * FROM DateSample
WHERE DateVal = ‘2002-02-28’
the result set includes only row 4 instead of both rows 2 and 4. That’s because the date literal is implicitly cast as a datetime value which, in this case, has a zero time component. Since this doesn’t exactly match the value in row 2, that row isn’t returned.
How can you get around the time component? If the query is run often, you should base the search on a range of values, as in:
SELECT * FROM DateSample
WHERE DateVal BETWEEN ‘2002-02-28’ AND ‘2002-02-28 23:59:59.997’
Remember that the BETWEEN clause retrieves values that are equal to the upper and lower limits, so you can’t code the upper limit as just ‘2002-02-29’. If you do, then you’ll incorrectly retrieve row 3. Another way to get the same result is to use comparison operators:
SELECT * FROM DateSample
WHERE DateVal >= ‘2002-02-28′ AND DateVal ’09:59′ AND TimeVal ’09:59′
AND TimeVal – CAST(FLOOR(CAST(TimeVal AS float)) AS datetime) < ’10:01′
which returns rows 1, 3, and 4. Again, though, there’s no way to accomplish this without the use of a function. So you may need to change the database design, if you can.
One other way to approximate time values is to use the smalldatetime data type rather than the datetime data type in the original table. Since smalldatetime always rounds the time portion to the nearest minute, times in the range from 09:59:29.999 to 10:00:29.998 are stored as 10:00. If approximation to the nearest whole minute is sufficient for your application, then using smalldatetime will prevent the need to search for a range of values.

SPEED UP PERFORMANCE BY USING AN INDEXED VIEW

Creating a unique clustered index on a view can drastically improve your
view performance because the view becomes stored in the database similar
to how a table is stored.

A standard view is built dynamically, and therefore, the overhead can be
enormous. With an indexed view, the results are stored, and what you
lose in data storage, you gain in performance.

The first index created on a view must be a unique clustered index. In
addition, the creator of the index must also own the tables. These tables,
as well as the view and index itself, must be created in the same
database.

Versions prior to SQL Server 2000 only allowed you to create indexes on
tables; SQL Server 2000, however, has added the ability to create indexes on views. SQL Server 2000 does this by storing the computed query
results and, when data in the view is changed, the index is changed. (The
results of standard views aren’t stored.)

Views have other restrictions, which include the following:

* You cannot have any other views, row set functions, inline functions,
or derived tables within the SELECT statement defining the indexed view.
You can’t have the keywords TOP, DISTINCT, COMPUTE, HAVING, and/or UNION
in the SELECT statement defining the indexed view. Also, the SELECT
statement can’t have a subquery.

* The SELECT list can’t have asterisks (*) or other wildcards. It cannot
have DISTINCT, COUNT(*), COUNT(), computed columns from the
base table or scalar aggregates.

* No OUTER JOIN operations are allowed in any joined tables.

* No subqueries or CONTAINS or FREETEXT predicates are allowed in the
search conditions.

* If the view definition contains a GROUP BY clause, all grouping
columns must appear in the view’s SELECT list. These columns also must be the
only columns in the CREATE UNIQUE CLUSTERED INDEX clause.

In addition, here are several system settings you must set in order to
use indexed views:

* NUMERIC_ROUNDABORT must be set to On. This allows the view to round
the result to the precision of the column or storing variable.

* ANSI_PADDING controls the way columns stores values shorter than the
defined size of the column.

* ANSI_WARNINGS specifies SQL-92 standard behavior for several error
conditions.

* CONCAT_NULL_YIELDS_NULL controls whether concatenation results are
treated as null or empty string values.

* ARITHABORT terminates a query when an overflow or divide-by-zero error
occurs during query execution.

* QUOTED_IDENTIFIER causes SQL Server to follow the SQL-92 rules
regarding quotation mark delimiting identifiers and literal strings.

The example below will create a view, then an index on that view, and
finally a query using the indexed view. But first, we have to adjust all
the system settings required to allow indexed views to work.

USE Northwind
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET
ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL,
ARITHABORT,QUOTED_IDENTIFIER,ANSI_NULLS ON
GO

Next, we’ll create a view called V1 that creates the columns Revenue,
OrderDate, and ProductID.

CREATE VIEW V1
WITH SCHEMABINDING
AS
SELECT SUM(UnitPrice*Quantity*(1.00-Discount)) AS Revenue,
OrderDate, ProductID, COUNT_BIG(*) AS COUNT
FROM dbo.[Order Details] od, dbo.Orders o
WHERE od.OrderID=o.OrderID
GROUP BY OrderDate, ProductID
GO

Next, we’ll create the unique clustered index on V1.

CREATE UNIQUE CLUSTERED INDEX IV1 ON V1 (OrderDate, ProductID)
GO

Finally, we’ll create a query that uses the indexed view instead of the
dynamic view.

SELECT SUM(UnitPrice*Quantity*(1.00-Discount)) AS Rev, OrderDate,
ProductID
FROM dbo.[Order Details] od, dbo.Orders o
WHERE od.OrderID=o.OrderID AND ProductID in
(2, 4, 25, 13, 7, 89, 22, 34)
AND OrderDate >= ’05/01/1998’
GROUP BY OrderDate, ProductID
ORDER BY Rev DESC

As you can see, indexed views aren’t easy, but the performance benefits
outweigh the cost in set-up time.

J.E. Harvey, MCSD, MCDBA, has been tinkering with and writing about
technology for more than two decades.

—————————————-
Microsoft ActiveX Data Objects (ADO)

Join the Discussion
“Share your questions and tap the knowledge of hundreds of your peers.”
Mike Chapple

Related Resources
• SQL Fundamentals
• Microsoft Access Fundamentals
• Retrieving Data with SQL Queries

If you’re like most database developers, you require frequent access to a wide variety of data sources — server-based databases, desktop databases, spreadsheets, text files and more. The thought of attempting to develop custom interfaces for each of those sources is enough to drive even the most dedicated software engineer off the deep end! Fortunately, if you’re developing in a Microsoft environment, ActiveX Data Objects relieve a large portion of that burden by providing an abstract high-level interface that works with nearly any data source.
Microsoft holds a dubious reputation in the software development industry based on their past efforts to crowd out competitors and force developers and end users to work in a strictly Microsoft environment. No so with ADO! In an attempt to keep developers from switching to non-platform-specific development environments like Java, Microsoft included ADO drivers for almost any data source you can imagine — text files, Oracle databases, IBM DB2 databases and Excel spreadsheets join the expected Access and SQL Server databases on the list of support products.
ADO is an application programmer’s interface (API) that provides developers with an easy way to access the underlying OLE DB data access interface. It’s part of Microsoft’s overall Component Object Model (COM) strategy and, as such, works in a variety of environments ranging from Visual Basic to Active Server Pages.
The ADO object model is actually quite simple — there are only six total objects:
• The Connection object sets up a link between your program and the data source. This object contains all of the necessary configuration information and acts as a gateway for all of the other ADO objects. The Connection object is mandatory — all implementations of ADO must support it.
• Each Connection object may have an associated collection of Error objects. ADO utilizes this collection when the connection returns more than one error message at a time. This collection is optional.
• The Command object represents a SQL statement or stored procedure that software executes against the datasource. Use of Command objects is optional — data can be extracted directly from a Connection object, if desired.
• Command objects may have an associated collection of Parameter objects that provide additional information to the data source when executing the command. The Parameter collection is optional.
• Each command execution results in a Recordset containing the results of the query. This object is a mandatory part of ADO.
• Each Recordset object is composed of a number of Field objects that represent individual columns in the Recordset. This object is a mandatory feature of ADO.
ADO provides a quick, easy way to access data from a variety of development environments. You won’t regret investing a few hours of your time in an exploration of the object model and it’s many uses.

USE FETCH RELATIVE TO FINE-TUNE YOUR SCROLL CURSORS

FETCH allows you to create SCROLL cursors that pull data from specific
rows by using arguments that determine exactly where you want to start
your cursor. These arguments include FIRST, LAST, PRIOR, and NEXT.

If you want to be even more exact, you can use the RELATIVE argument to
return rows in relation to the cursor position:

RELATIVE {n}

A positive integer returns rows after the current cursor position, and a
negative integer returns rows prior to the cursor position.

The following example creates an authors_cursor from the pubs database
that pulls data from the third row after the cursor position:

USE pubs
GO

— Declare the cursor.
DECLARE authors_cursor SCROLL CURSOR FOR
SELECT au_lname, au_fname FROM authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

— Fetch the row that is three rows after the current row.
FETCH RELATIVE 3 FROM authors_cursor

CLOSE authors_cursor
DEALLOCATE authors_cursor
GO

You also can use FETCH RELATIVE to search rows prior to the cursor
position. In the example below, we will first position the cursor on the last
row, and then fetch data from the row located two rows away:

USE pubs
GO

— Declare the cursor.
DECLARE authors_cursor SCROLL CURSOR FOR
SELECT au_lname, au_fname FROM authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

— Fetch the row at the end of the table.
FETCH LAST FROM authors_cursor

— Fetch the row that is two rows prior to the current row.
FETCH RELATIVE -2 FROM authors_cursor

CLOSE authors_cursor
DEALLOCATE authors_cursor
GO

—————————————-

Use This SP to Generate a SQL Server Job Report

by Sekhar Mynam
Have you ever wanted to create a report listing all of the SQL Server jobs on your SQL Server 7.0 or 2000 servers? This is easy if you use the stored procedure I have created just for this purpose. The stored procedure, called sp_JobSchedule_rpt, creates this report by joining the sysjobs and sysjobschedules tables and creating a resultset.
To make the report easy to read, I have had to substitute the various integer values found in these tables with readable values. The first part of the stored procedure generates the list of jobs and the days to run for weekly scheduled jobs. The second part is written with CASE statements to incorporate all the possible combinations listed under the sysjobschedules table.
Making the Data Readable
The following are the various numeric entries and their string values, used in the stored procedure, to make it more readable.

freq_type int Frequency of the schedule execution:
1 = Once
4 = Daily
8 = Weekly
16 = Monthly
32 = Monthly relative
64 = Execute when SQL Server

freq_interval int Value indicating on which days the schedule runs.

If freq_type is 4 (daily), the value is every freq_interval days.

If freq_type is 8 (weekly), the value is a bitmask indicating the days in which weekly schedules are run. The freq_interval values are:
1 = Sunday
2 = Monday
4 = Tuesday
8 = Wednesday
16 = Thursday
32 = Friday
64 = Saturday

If freq_type is 16 (monthly), the value is freq_interval day of the month.

If freq_type is 32 (monthly relative), freq_interval can be one of these values:
1 = Sunday
2 = Monday
3 = Tuesday
4 = Wednesday
5 = Thursday
6 = Friday
7 = Saturday
8 = Day
9 = Weekday
10 = Weekend day

freq_subday_type int Units for the freq_subday_interval:
1 = At the specified time
2 = Seconds
4 = Minutes
8 = Hours

freq_subday_interval int Number of freq_subday_type periods to occur between each scheduled execution of the job.

freq_relative_interval int Scheduled job’s occurrence of the freq_interval in each month when freq_type is 32 (monthly relative):
1 = First
2 = Second
4 = Third
8 = Fourth
16 = Last

freq_recurrence_factor int Number of weeks or months between the scheduled execution of the job.
Running the Stored Procedure
The following stored procedure is best created in the master database, although it is not required. Once the stored procedure has been created, it is executed without any parameters.

CREATE PROCEDURE sp_JobSchedule_rpt

AS

declare @x int, @y int, @z int
declare @counter smallint
declare @days varchar(100), @day varchar(10)
declare @Jname sysname, @freq_interval int, @JID varchar(50)
SET NOCOUNT ON

create table #temp (JID varchar(50), Jname sysname,
Jdays varchar(100))
–This cursor runs throough all the jobs that have a weekly frequency running on different days
Declare C cursor for select Job_id, name, freq_interval from msdb..sysjobschedules
where freq_type = 8
Open C
Fetch Next from c into @JID, @Jname, @freq_interval
while @@fetch_status = 0
Begin
set @counter = 0
set @x = 64
set @y = @freq_interval
set @z = @y
set @days = ”
set @day = ”

while @y 0
begin
select @y = @y – @x
select @counter = @counter + 1
If @y < 0
Begin
set @y = @z
GOTO start
End

Select @day = CASE @x
when 1 Then ‘Sunday’
when 2 Then ‘Monday’
when 4 Then ‘Tuesday’
when 8 Then ‘Wednesday’
when 16 Then ‘Thursday’
when 32 Then ‘Friday’
when 64 Then ‘Saturday’
End

select @days = @day + ‘,’ + @days
start:
Select @x = CASE @counter
When 1 then 32
When 2 then 16
When 3 then 8
When 4 then 4
When 5 then 2
When 6 then 1
End

set @z = @y

if @y = 0 break
end

Insert into #temp select @jid, @jname, left(@days, len(@days)-1)
Fetch Next from c into @jid, @Jname, @freq_interval

End
close c
deallocate c

–Final query to extract complete information by joining sysjobs, sysjobschedules and #Temp table

select b.name Job_Name,
CASE b.enabled
when 1 then ‘Enabled’
Else ‘Disabled’
End as JobEnabled, a.name Schedule_Name,

CASE a.enabled
when 1 then ‘Enabled’
Else ‘Disabled’
End as ScheduleEnabled,

CASE freq_type
when 1 Then ‘Once’
when 4 Then ‘Daily’
when 8 then ‘Weekly’
when 16 Then ‘Monthly’ –+ cast(freq_interval as char(2)) + ‘th Day’
when 32 Then ‘Monthly Relative’
when 64 Then ‘Execute When SQL Server Agent Starts’
End as [Job Frequency],

CASE freq_type
when 32 then CASE freq_relative_interval
when 1 then ‘First’
when 2 then ‘Second’
when 4 then ‘Third’
when 8 then ‘Fourth’
when 16 then ‘Last’
End
Else ”
End as [Monthly Frequency],

CASE freq_type
when 16 then cast(freq_interval as char(2)) + ‘th Day of Month’
when 32 then CASE freq_interval
when 1 then ‘Sunday’
when 2 then ‘Monday’
when 3 then ‘Tuesday’
when 4 then ‘Wednesday’
when 5 then ‘Thursday’
when 6 then ‘Friday’
when 7 then ‘Saturday’
when 8 then ‘Day’
when 9 then ‘Weekday’
when 10 then ‘Weekend day’
End
when 8 then c.Jdays
Else ”
End as [Runs On],
CASE freq_subday_type
when 1 then ‘At the specified Time’
when 2 then ‘Seconds’
when 4 then ‘Minutes’
when 8 then ‘Hours’
End as [Interval Type], CASE freq_subday_type
when 1 then 0
Else freq_subday_interval
End as [Time Interval],
CASE freq_type
when 8 then cast(freq_recurrence_factor as char(2)) + ‘ Week’
when 16 Then cast(freq_recurrence_factor as char(2)) + ‘ Month’
when 32 Then cast(freq_recurrence_factor as char(2)) + ‘ Month’
Else ”
End as [Occurs Every],

left(active_start_date,4) + ‘-‘ + substring(cast(active_start_date as char),5,2)
+ ‘-‘ + right(active_start_date,2) [Begin Date-Executing Job],

left(REPLICATE(‘0’, 6-len(active_start_time)) + cast(active_start_time as char(6)),2) + ‘:’ +
substring(REPLICATE(‘0’, 6-len(active_start_time)) + cast(active_start_time as char(6)),3,2) + ‘:’ +
substring(REPLICATE(‘0’, 6-len(active_start_time)) + cast(active_start_time as char(6)),5,2)
[Executing At],

left(active_end_date,4) + ‘-‘ + substring(cast(active_end_date as char),5,2)
+ ‘-‘ + right(active_end_date,2) [End Date-Executing Job],

left(REPLICATE(‘0’, 6-len(active_end_time)) + cast(active_end_time as char(6)),2) + ‘:’ +
substring(REPLICATE(‘0’, 6-len(active_end_time)) + cast(active_end_time as char(6)),3,2) + ‘:’ +
substring(REPLICATE(‘0’, 6-len(active_end_time)) + cast(active_end_time as char(6)),5,2)
[End Time-Executing Job],

b.date_created [Job Created], a.date_created [Schedule Created]
from msdb..sysjobschedules a RIGHT OUTER JOIN msdb..sysjobs b ON a.job_id = b.job_id
LEFT OUTER JOIN #temp c on a.name = c.jname and a.job_id = c.Jid

Order by 1

Drop Table #Temp

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Working With User Profiles
By: Brien M. Posey, MCSE

What’s a User Profile?

One of the main reasons that sharing a system between multiple users is difficult is that any change that one user makes to the PC affects all of the other users, too. For example, I once worked in an office where two users who shared a PC constantly fought over the Windows color scheme. One user would change it and the other user would change it right back. Having users fight over color schemes can be annoying, but much worse things can happen when users share PCs. I once saw a user who didn’t know any better accidentally erase the contents of the My Documents folder, which of course contained documents for everyone in the entire department.

One way of getting around these problems is to implement user profiles. User profiles provide each user with a unique computing experience. All users have to do is enter a password and they are taken into a session that’s been custom tailored specifically to their needs or likes.

As I’ll explain later on, perhaps the most noticeable of these custom attributes is the Windows desktop. Now, if Joe erases an icon, he’ll only erase it for himself. The other users won’t be affected. Likewise, if Bob wants a blue desktop and Billy wants a red desktop, they can both have what they want.

Custom desktops, however, are only the beginning. As I’ll explain in the next section, there are plenty of other custom attributes that are included with a user’s profile. You can also do things such as make users’ custom profiles follow them from machine to machine. Or if you prefer, you can dictate a mandatory profile, containing settings that the users can’t change. Regardless of what your preferences are, user profiles are highly customizable from both a user and an administrative perspective.

What’s New In Microsoft® SQL Server™ 2000 ?
Relational Database Enhancements
Microsoft® SQL Server™ 2000 introduces several server improvements and new
features :
1. XML Support – The relational database engine can return data as Extensible
Markup Language (XML) documents. Additionally, XML can also be used to insert,
update, and delete values in the database.
2. Federated Database Servers – SQL Server 2000 supports enhancements to
distributed partitioned views that allow you to partition tables horizontally across
multiple servers. This allows you to scale out one database server to a group of
database servers that cooperate to provide the same performance levels as a
cluster of database servers. This group, or federation, of database servers can
support the data storage requirements of the largest Web sites and enterprise data
processing systems.
3. User-Defined Functions – The programmability of Transact-SQL can be
extended by creating your own Transact-SQL functions. A user-defined function
can return either a scalar value or a table.
4. Indexed Views – Indexed views can significantly improve the performance of an
application where queries frequently perform certain joins or aggregations. An
indexed view allows indexes to be created on views, where the result set of the
view is stored and indexed in the database. Existing applications do not need to be
modified to take advantage of the performance improvements with indexed views.
5. New Data Types – SQL Server 2000 introduces three new data types. bigint is an
8-byte integer type. sql_variant is a type that allows the storage of data values of
different data types. table is a type that allows applications to store results
temporarily for later use. It is supported for variables, and as the return type for
user-defined functions.
6. INSTEAD OF and AFTER Triggers – INSTEAD OF triggers are executed instead
of the triggering action (for example, INSERT, UPDATE, DELETE). They can also be
defined on views, in which case they greatly extend the types of updates a view
can support. AFTER triggers fire after the triggering action. SQL Server 2000
introduces the ability to specify which AFTER triggers fire first and last.
7. Cascading Referential Integrity Constraints – You can control the actions SQL
Server 2000 takes when you attempt to update or delete a key to which existing
foreign keys point. This is controlled by the new ON DELETE and ON UPDATE
clauses in the REFERENCES clause of the CREATE TABLE and ALTER TABLE
statements.
What’s New In Microsoft® SQL Server™ 2000 ?
8. Collation Enhancements – SQL Server 2000 replaces code pages and sort orders
with collations. SQL Server 2000 includes support for most collations supported in
earlier versions of SQL Server, and introduces a new set of collations based on
Windows collations. You can now specify collations at the database level or at the
column level. Previously, code pages and sort orders could be specified only at the
server level and applied to all databases on a server. Collations support code page
translations. Operations with char and varchar operands having different code
pages are now supported. Code page translations are not supported for text
operands. You can use ALTER DATABASE to change the default collation of a
database.
9. Full-Text Search Enhancements – Full-text search now includes change
tracking and image filtering. Change tracking maintains a log of all changes to the
full-text indexed data. You can update the full-text index with these changes by
flushing the log manually, on a schedule, or as they occur, using the background
update index option. Image filtering allows you to index and query documents
stored in image columns. The user provides the document type in a column that
contains the file name extension that the document would have had if it were
stored as a file in the file system. Using this information, full-text search is able to
load the appropriate document filter to extract textual information for indexing.
10. Multiple Instances of SQL Server – SQL Server 2000 supports running multiple
instances of the relational database engine on the same computer. Each computer
can run one instance of the relational database engine from SQL Server version
6.5 or 7.0, along with one or more instances of the database engine from SQL
Server 2000. Each instance has its own set of system and user databases.
Applications can connect to each instance on a computer similar to the way they
connect to instances of SQL Servers running on different computers. The SQL
Server 2000 utilities and administration tools have been enhanced to work with
multiple instances.
11. Index Enhancements – You can now create indexes on computed columns. You
can specify whether indexes are built in ascending or descending order, and if the
database engine should use parallel scanning and sorting during index creation.
The CREATE INDEX statement can now use the tempdb database as a work area
for the sorts required to build an index. This results in improved disk read and
write patterns for the index creation step, and makes it more likely that index
pages will be allocated in contiguous strips. In addition, the complete process of
creating an index is eligible for parallel operations, not only the initial table scan.
12. Failover Clustering Enhancements – The administration of failover clusters has
been greatly improved to make it very easy to install, configure, and maintain a
Microsoft SQL Server 2000 failover cluster. Additional enhancements include the
What’s New In Microsoft® SQL Server™ 2000 ?
ability to failover and failback to or from any node in a SQL Server 2000 cluster,
the ability to add or remove a node from the cluster through SQL Server 2000
Setup, and the ability to reinstall or rebuild a cluster instance on any node in the
cluster without affecting the other cluster node instances. The SQL Server 2000
utilities and administration tools have been enhanced to work with failover
clusters.
13. Net-Library Enhancements – The SQL Server 2000 Net-Libraries have been
rewritten to virtually eliminate the need to administer Net-Library configurations
on client computers when connecting SQL Server 2000 clients to instances of SQL
Server 2000. The new Net-Libraries also support connections to multiple instances
of SQL Server on the same computer, and support Secure Sockets Layer
encryption over all Net-Libraries. SQL Server 2000 introduces Net-Library support
for Virtual Interface Architecture (VIA) system-area networks that provide highspeed
connectivity between servers, such as between application servers and
database servers.
14. 64-GB Memory Support – Microsoft SQL Server 2000 Enterprise Edition can use
the Microsoft Windows 2000 Advanced Windows Extension (AWE) API to support
up to 64 GB of physical memory (RAM) on a computer.
15. Distributed Query Enhancements – SQL Server 2000 introduces a new
OPENDATASOURCE function, which you can use to specify ad hoc connection
information in a distributed query. SQL Server 2000 also specifies methods that
OLE DB providers can use to report the level of SQL syntax supported by the
provider and statistics on the distribution of key values in the data source. The
distributed query optimizer can then use this information to reduce the amount of
data that has to be sent from the OLE DB data source. SQL Server 2000 delegates
more SQL operations to OLE DB data sources than earlier versions of SQL Server.
Distributed queries also support the other functions introduced in SQL Server
2000, such as multiple instances, mixing columns with different collations in result
sets, and the new bigint and sql_variant data types. SQL Server 2000 distributed
queries add support for the OLE DB Provider for Exchange and the Microsoft OLE
DB Provider for Microsoft Directory Services.
16. Updatable Distributed Partitioned Views – SQL Server 2000 introduces
enhancements to distributed partitioned views. You can partition tables
horizontally across several servers, and define a distributed partitioned view on
each member server that makes it appear as if a full copy of the original table is
stored on each server. Groups of servers running SQL Server that cooperate in this
type of partitioning are called federations of servers. A database federation built
using SQL Server 2000 databases is capable of supporting the processing
requirements of the largest Web sites or enterprise-level databases.
What’s New In Microsoft® SQL Server™ 2000 ?
17. Kerberos and Security Delegation – SQL Server 2000 uses Kerberos to support
mutual authentication between the client and the server, as well as the ability to
pass the security credentials of a client between computers, so that work on a
remote server can proceed using the credentials of the impersonated client. With
Microsoft Windows® 2000, SQL Server 2000 uses Kerberos and delegation to
support both integrated authentication as well as SQL Server logins.
18. Backup and Restore Enhancements – SQL Server 2000 introduces a new, more
easily understood model for specifying backup and restore options. The new model
makes it clearer that you are balancing increased or decreased exposure to losing
work against the performance and log space requirements of different plans. SQL
Server 2000 introduces support for recovery to specific points of work using
named log marks in the transaction log, and the ability to do partial database
restores. Users can define passwords for backup sets and media sets that prevent
unauthorized users from accessing SQL Server backups.
19. Scalability Enhancements for Utility Operations – SQL Server 2000
enhancements for utility operations include faster differential backups, parallel
Database Console Command (DBCC) checking, and parallel scanning. Differential
backups can now be completed in a time that is proportional to the amount of data
changed since the last full backup. DBCC can be run without taking shared table
locks while scanning tables, thereby enabling them to be run concurrently with
update activity on tables. Additionally, DBCC now takes advantage of multiple
processors, thus enabling near-linear gain in performance in relation to the
number of CPUs (provided that I/O is not a bottleneck).
20. Text in Row Data – SQL Server 2000 supports a new text in row table option
that specifies that small text, ntext, and image values be placed directly in the
data row instead of in a separate page. This reduces the amount of space used to
store small text, ntext, and image data values, and reduces the amount of disk I/O
needed to process these values.
XML Integration of Relational Data
The Microsoft® SQL Server™ 2000 relational database engine natively supports
Extensible Markup Language (XML). You can now access SQL Server 2000 over HTTP
using a Universal Resource Locator (URL). You can define a virtual root on a Microsoft
Internet Information Services (IIS) server, which gives you HTTP access to the data
and XML functionality of SQL Server 2000.
What’s New In Microsoft® SQL Server™ 2000 ?
You can use HTTP, ADO, or OLE DB to work with the XML functionality of SQL Server
2000:
1. You can define XML views of SQL Server 2000 databases by annotating XML-Data
Reduced (XDR) schemas to map the tables, views, and columns that are
associated with the elements and attributes of the schema. The XML views can
then be referenced in XPath queries, which retrieve results from the database and
return them as XML documents.
2. The results of SELECT statements can be returned as XML documents. The SQL
Server 2000 Transact-SQL SELECT statement supports a FOR XML clause that
specifies that the statement results be returned in the form of an XML document
instead of a relational result set. Complex queries, or queries that you want to
make secure, can be stored as templates in an IIS virtual root, and executed by
referencing the template name.
3. You can expose the data from an XML document as a relational rowset using the
new OPENXML rowset function. OPENXML can be used everywhere a rowset
function can be used in a Transact-SQL statement, such as in place of a table or
view reference in a FROM clause. This allows you to use the data in XML
documents to insert, update, or delete data in the tables of the database, including
modifying multiple rows in multiple tables in a single operation.
Graphical Administration Enhancements
Microsoft® SQL Server™ 2000 introduces these graphical administration
improvements and new features:
1. Log Shipping – Log shipping allows the transaction logs from a source database
to be continually backed up and loaded into a target database on another server.
This is useful for maintaining a warm standby server, or for offloading query
processing from the source server to a read-only destination server.
2. SQL Profiler Enhancements – SQL Profiler now supports size-based and timebased
traces, and includes new events for Data File Auto Grow, Data File Auto
Shrink, Log File Auto Grow, Log File Auto Shrink, Show Plan All, Show Plan
Statistics, and Show Plan Text. SQL Profiler has been enhanced to provide auditing
of SQL Server activities, up to the auditing levels required by the C2 level of
security defined by the United States government.
3. SQL Query Analyzer Enhancements – SQL Query Analyzer now includes Object
Browser, which allows you to navigate through and get information (such as
parameters and dependencies) about database objects, including user and system
tables, views, stored procedures, extended stored procedures, and functions. The
What’s New In Microsoft® SQL Server™ 2000 ?
Object Browser also supports generating scripts to either execute or create
objects. Other enhancements include server tracing and client statistics that show
information about the server-side and client-side impact of a given query. SQL
Query Analyzer includes a stored procedure debugger. SQL Query Analyzer also
includes templates that can be used as the starting points for creating objects such
as databases, tables, views, and stored procedures.
4. Copy Database Wizard – Users can run the Copy Database Wizard to upgrade
SQL Server version 7.0 databases to SQL Server 2000 databases. It can also be
used to copy complete databases between instances of SQL Server 2000.
Replication Enhancements
Microsoft® SQL Server™ 2000 introduces the following replication improvements and
new features:
1. Implementing Replication – SQL Server 2000 enhances snapshot replication,
transactional replication, and merge replication by adding:
• Alternate snapshot locations.
• Attachable subscription databases.
• Schema changes on publication databases.
• On demand script execution.
• Pre- and post-snapshot scripts.
• Remote agent activation.
• Support of new SQL Server features, which includes user-defined functions,
indexed views, new data types, and multiple instances of SQL Server.
• The ActiveX Snapshot Control, which makes programmatic generation of
snapshots easier.
• More snapshot scripting options, which support transfer of indexes, extended
properties, and constraints to Subscribers.
2. Merge Replication – Merge replication is the process of distributing data from
Publisher to Subscribers, allowing the Publisher and Subscribers to make updates
while connected or disconnected, and then merging the changes between sites
when they are connected. Enhancements to merge replication include:
• Greater parallelism of the Merge Agent for improved server-to-server
performance.
• Optimizations for determining data changes relevant to a partition at a
Subscriber.
What’s New In Microsoft® SQL Server™ 2000 ?
• Dynamic snapshots, which provide more efficient application of the initial
snapshot when using dynamic filters.
• Vertical filters for merge publications.
• More powerful dynamic filtering with user-defined functions.
• The ability to use alternate synchronization partners when synchronizing data.
• Automated management of identity ranges.
• Support for timestamp columns in published tables.
• Improved management of the growth of merge tracking data.
• Several new merge replication conflict resolvers including interactive resolvers
that provide a user interface for immediate, manual conflict resolution, priority
based on a column value, minimum/maximum value wins, first/last change
wins, additive/average value, and merge by appending different text values.
• New options to validate permissions for a Subscriber to upload changes to a
Publisher (check_permissions) and security enhancements including code
signing of conflict resolvers included with Microsoft SQL Server 2000.
• New COM interfaces that support heterogeneous data sources as Publishers
within a SQL Server replication topology.
• Validation of replicated data per subscription or on a publication-wide basis.
Validation is also available through SQL Server Enterprise Manager.
• Reinitialization to allow uploading of changes from the Subscriber before the
application of a new snapshot.
3. Transactional Replication – With transactional replication, an initial snapshot of
data is applied at Subscribers, and then when data modifications are made at the
Publisher, the individual transactions are captured and propagated to Subscribers.
Enhancements to transactional replication include:
• Concurrent snapshot processing so that data modifications can continue on
publishing tables while the initial snapshot is generated.
• Improved error handling and the ability to skip specified errors and continue
replication.
• Validation of replicated data at the Subscriber, including validation on vertical
partitions. Validation is also available through SQL Server Enterprise Manager.
• Publishing indexed views as tables.
• The option to store data modifications made at the Subscriber in a queue
(queued updating).
• The option to transform data as it is published to Subscribers (transforming
published data).
• The ability to restore transactional replication databases without reinitializing
subscriptions or disabling and reconfiguring publishing and distribution. You
What’s New In Microsoft® SQL Server™ 2000 ?
can also set up transactional replication to work with log shipping, enabling
you to fail over to a warm standby server without reconfiguring replication.
4. Queued Updating – Queued updating allows snapshot replication and
transactional replication Subscribers to modify published data without requiring an
active network connection to the Publisher. When you create a publication with the
queued updating option enabled and a Subscriber performs INSERT, UPDATE, or
DELETE statements on published data, the changes are stored in a queue. The
queued transactions are applied asynchronously at the Publisher when network
connectivity is restored. Because the updates are propagated asynchronously to
the Publisher, the same data may have been updated by the Publisher or by
another Subscriber and conflicts can occur when applying the updates. Conflicts
are detected automatically and several options for resolving conflicts are offered.
5. Transforming Published Data – Transformable subscriptions (available with
snapshot replication or transactional replication) leverages the data movement,
transformation mapping, and filtering capabilities of Data Transformation Services
(DTS). Using transformable subscriptions in your replication topology allows you to
customize and send published data based on the requirements of individual
Subscribers, including performing data type mappings, column manipulations,
string manipulations, and use of functions as data is published.
6. Replication Usability – There have been several improvements in SQL Server
Enterprise Manager that provide for easier implementation, monitoring, and
administration of replication. Enhancements to replication usability include:
• A centralized Replication folder in the SQL Server Enterprise Manager tree,
which organizes all subscriptions and publications on the server being
administered.
• The ability to browse for and subscribe to publications (when permission is
allowed) using Windows Active Directory.
• The ability to see multiple Distributors in a single monitoring node in SQL
Server Enterprise Manager.
• Standard and advanced replication options separated in the Create Publication,
Create Push Subscription, and Create Pull Subscription Wizards. You can
choose to show advanced options in these wizards on the Welcome page of
each wizard.
• New wizards for creating jobs that create dynamic snapshots for merge
publications that use dynamic filters (Create Dynamic Snapshot Job Wizard),
What’s New In Microsoft® SQL Server™ 2000 ?
and for transforming published data in snapshot replication or transactional
replication (Transform Published Data Wizard).
Data Transformation Services Enhancements
Microsoft® SQL Server™ 2000 introduces these Data Transformation Services (DTS)
enhancements and new features :
1. New Custom Tasks – New DTS custom tasks, available through DTS Designer or
the DTS object model, allow you to create DTS packages that perform tasks or set
variables based on the properties of the run-time environment. Use these tasks to:
• Import data from, and send data and completed packages to, Internet and File
Transfer Protocol (FTP) sites.
• Run packages asynchronously.
• Build packages that send messages to each other.
• Build packages that execute other packages.
• Join multiple package executions as part of a transaction.
2. Enhanced Logging Facilities – DTS package logs save information for each
package execution, allowing you to maintain a complete execution history. You can
also view execution information for individual processes within a task. You can
generate exception files for transformation tasks. When you log to exception files,
you can save source and destination error rows to a file through the DTS OLE DB
text file provider and re-process the error rows.
3. Saving DTS Packages to Visual Basic Files – DTS packages now can be saved
to a Microsoft® Visual Basic® file. This allows a package created by the DTS
Import/Export Wizard or DTS Designer to be incorporated into Visual Basic
programs or to be used as prototypes by Visual Basic developers who need to
reference the components of the DTS object model. For more information, see
Saving a DTS Package.
4. Using the Multiphase Data Pump – A new multiphase data pump allows
advanced users to customize the operation of the data pump at various stages of
its operation. You can now use global variables as input and output parameters for
queries. For more information, see Multiphase Data Pump Functionality..
What’s New In Microsoft® SQL Server™ 2000 ?
5. Using Parameterized Queries – You can now use parameterized source queries
in a DTS transformation task and an Execute SQL task. In addition, DTS includes
an option for saving the results of a parameterized query to a global variable,
allowing you to perform functions such as saving disconnected Microsoft ActiveX®
Data Objects (ADO) recordsets in DTS. For more information, see Using
Parameterized Queries in DTS.
6. Using Global Variables to Pass Information Between DTS Packages – You
now can use the Execute Package task to dynamically assign the values of global
variables from a parent package to a child package. Use global variables to pass
information from one package to another when each package performs different
work items. For example, use one package to download data on a nightly basis,
summarize the data, assign summary data values to global variables, and pass the
values to another package that further processes the data.
Analysis Services Enhancements
Microsoft® SQL Server™ 2000 extends and renames the former OLAP Services
component, now called Analysis Services. Many new and improved features
significantly enhance the analysis capabilities of the acclaimed OLAP Services
introduced in SQL Server version 7.0. In this release, Analysis Services introduces data
mining, which can be used to discover information in OLAP cubes and relational
databases.
Meta Data Services Enhancements
Microsoft® SQL Server™ 2000 Meta Data Services includes the former Microsoft
Repository. Microsoft® SQL Server™ 2000 Meta Data Services is an object-oriented
repository technology that can be integrated with enterprise information systems or
with applications that process meta data.
A number of Microsoft technologies use Meta Data Services as a native store for object
definitions or as a platform for deploying meta data. One of the ways in which SQL
Server 2000 uses Meta Data Services is to store versioned Data Transformation
Services (DTS) packages. In Microsoft Visual Studio®, Meta Data Services supports
the exchange of model data with other development tools.
What’s New In Microsoft® SQL Server™ 2000 ?
You can use Meta Data Services for your own purposes: as a component of an
integrated information system, as a native store for custom applications that process
meta data, or as a storage and management service for sharing reusable models. You
can also extend Meta Data Services to provide support for new tools for resale or
customize it to satisfy internal tool requirements.
English Query Enhancements
English Query introduces new features such as:
1. Greater integration with Microsoft® Visual Studio®, Analysis Services, and Full-
Text Search.
2. A graphical user interface for English Query authoring.
3. The SQL Project Wizard.
4. An XML-based language for persisting English Query model information.

Komentar
  1. senopatiarthur berkata:

    Promosikan artikel anda di http://www.infogue.com. Telah tersedia widget shareGue dan pilihan widget lainnya serta nikmati fitur info cinema, game online & kamus online untuk para netter Indonesia. Salam!
    http://database.infogue.com/pengenalan_sql_server

  2. njell89 berkata:

    thanz ‘u much it’s all goods i like you book.

  3. Vickey berkata:

    Excellent article. I certainly love this website.

    Continue the good work!

  4. diet drops yipiz berkata:

    I do accept as true with all the ideas you have offered on your post.
    They are very convincing and can certainly work.

    Still, the posts are too quick for starters. May just you please
    prolong them a little from next time? Thanks for the post.

  5. Hey! I know this is kinda off topic nevertheless I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a blog article or
    vice-versa? My blog goes over a lot of the
    same subjects as yours and I think we could greatly benefit from each other.

    If you happen to be interested feel free to send me an email.
    I look forward to hearing from you! Fantastic blog by the way!

  6. Marlon berkata:

    If some one wants expert view regarding running a blog after that i propose him/her to pay a quick visit this web
    site, Keep up the nice work.

  7. domino berkata:

    I together with my pals ended up digesting the excellent tips and hints found on the
    website while all of a sudden came up with an awful
    suspicion I had not thanked you for those strategies.
    These guys became totally passionate to read them and have surely been making the most of
    these things. Appreciation for simply being simply accommodating and for using variety of
    useful issues millions of individuals are really
    desperate to discover. Our sincere regret for not expressing gratitude to sooner.

    my blog: domino

Tinggalkan komentar