Tuesday, December 18, 2007

Make Your Site to Your Homepage - Script

This is Script for set your browser home page

<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://vinothtech.blogspot.com');">Make this Your HomePage!</a>

Sample: Make this Your HomePage!

Thursday, November 1, 2007

What is Primary key?

A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself, or it can be an artificial field (one that has nothing to do with the actual record). A table can have only one primary key. A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.

Below are examples for specifying a primary key when creating a table:

MySQL:
CREATE TABLE Customer
(SID integer,
Last_Name varchar(30),
First_Name varchar(30),
PRIMARY KEY (SID));

Oracle:
CREATE TABLE Customer
(SID integer PRIMARY KEY,
Last_Name varchar(30),
First_Name varchar(30));

SQL Server:
CREATE TABLE Customer
(SID integer PRIMARY KEY,
Last_Name varchar(30),
First_Name varchar(30));

Below are examples for specifying a primary key by altering a table:

MySQL:
ALTER TABLE Customer ADD PRIMARY KEY (SID);
Oracle:
ALTER TABLE Customer ADD PRIMARY KEY (SID);
SQL Server:
ALTER TABLE Customer ADD PRIMARY KEY (SID);

Note: Before using the ALTER TABLE command to add a primary key, you'll need to make sure that the field is defined as 'NOT NULL' -- in other words, NULL cannot be an accepted value for that field.

Wednesday, October 31, 2007

Backup a Database Using Query

1.Full Backup


declare @Path varchar(500) ,
@DBName varchar(128)

select @DBName = 'msdb'
select @Path = 'c:\backups\'

declare @FileName varchar(4000)
select @FileName = @Path + @DBName + '_Full_'
+ convert(varchar(8),getdate(),112) + '_'
+ replace(convert(varchar(8),getdate(),108),':','')
+ '.bak'

backup database @DBName
to disk = @FileName


2. Diff Backup


declare @Path varchar(500) ,
@DBName varchar(128)

select @DBName = 'msdb'
select @Path = 'c:\backups\'

declare @FileName varchar(4000)
select @FileName = @Path + @DBName + '_Diff_'
+ convert(varchar(8),getdate(),112) + '_'
+ replace(convert(varchar(8),getdate(),108),':','')
+ '.bak'

backup database @DBName
to disk = @FileName
with differential


3.Log Backup


declare @Path varchar(500) ,
@DBName varchar(128)

select @DBName = 'msdb'
select @Path = 'c:\backups\'

declare @FileName varchar(4000)
select @FileName = @Path + @DBName + '_Log_'
+ convert(varchar(8),getdate(),112) + '_'
+ replace(convert(varchar(8),getdate(),108),':','')
+ '.bak'

backup log @DBName
to disk = @FileName

4.Restore Backup

declare @Path varchar(500) ,
@DBName varchar(128)

select @DBName = 'msdb'
select @Path = 'c:\backups\'

declare @FileName varchar(4000)
select @FileName = @Path + @DBName + '_Log_'
+ convert(varchar(8),getdate(),112) + '_'
+ replace(convert(varchar(8),getdate(),108),':','')
+ '.bak'


Restore Database @DBName From Disk = @FileName With Replace, Move 'Msdb_Data' To @Path + @DBName + '_Data.MDF', Move 'Msdb4_Log' To @Path + @DBName + '_Log.LDF'