jump to navigation

SQL SERVER : Semuanya Lewat Script (1) July 14, 2006

Posted by sarach in SQL Server, Tips Programming, Visual Basic, Web Master.
trackback
Sql Server Berikut ini saya posting beberapa script SQL untuk database Ms SQL SERVER permintaan dari rekan saya dan juga beberapa email yg masuk ke saya (terima kasih atas inputannya..😉 ).
Scripty yg  akan saya tampilkan pada sesi ini dimulai dari create database sampai Create Index di Table.


1. Create Database

1. Paling Simple CREATE DATABASE mydatabase
2. Simple CREATE DATABASE Products
ON
( NAME = prods_dat,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\prods.mdf’,
SIZE = 4,
MAXSIZE = 10,
FILEGROWTH = 1 )
3. Normal CREATE DATABASE Archive
ON
PRIMARY ( NAME = Arch1,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\archdat1.mdf’,
SIZE = 100MB,
MAXSIZE = 200,
FILEGROWTH = 20),
( NAME = Arch2,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\archdat2.ndf’,
SIZE = 100MB,
MAXSIZE = 200,
FILEGROWTH = 20),
( NAME = Arch3,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\archdat3.ndf’,
SIZE = 100MB,
MAXSIZE = 200,
FILEGROWTH = 20)
LOG ON
( NAME = Archlog1,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\archlog1.ldf’,
SIZE = 100MB,
MAXSIZE = 200,
FILEGROWTH = 20),
( NAME = Archlog2,
FILENAME = ‘c:\program files\microsoft sql server\mssql\data\archlog2.ldf’,
SIZE = 100MB,
MAXSIZE = 200,
FILEGROWTH = 20)

2. Create Table  (Unless it has already been created)

if not exists (select * from sysobjects where name=’cars’ and xtype=’U’)
    create table cars (
        Name varchar(64) not null
    )
go

3. Create an View on a table (Unless it has already been created)

if not exists (select * from sysobjects where name=’cars’ and xtype=’V’)
    exec (‘create view cars as select * from vans where type=1’)
go

4. Create an Index on a table (Unless it has already been created)

if not exists (select * from sysindexes
where id=object_id(‘Employees’) and name=’IE1Employee’)
create index IE1Employee on Employees(name)
go

Bersambung …

visit : https://pondokindah.wordpress.com/

Comments

1. sriyanto - May 2, 2008

Lam kenal saya kesilitan dalam pembuatan data siswa beserta perintahnya tlng dong kirimin?

2. Yopie - June 11, 2008

Kalo dengan VB6 atau VB.NET syntax-nya sama gak ? Thanks


Sorry comments are closed for this entry

%d bloggers like this: