uniqueidentifier In MS SQL

uniqueidentifier In MS SQL

 

Example

create table t1

(

  id uniqueidentifier DEFAULT NEWSEQUENTIALID(),

  name varchar(max)

);

 

insert into t1(name) values('Vidya Gyan 1');

insert into t1(name) values('Vidya Gyan 2');

insert into t1(name) values('Vidya Gyan 3');

select * From t1;

 

 

Microsoft Says

Comparison operators can be used with uniqueidentifier values. However, ordering is not implemented by comparing the bit patterns of the two values. The only operations that can be performed against a uniqueidentifier value are comparisons (=, <>, <, >, <=, >=) and checking for NULL (IS NULL and IS NOT NULL). No other arithmetic operators can be used. All column constraints and properties, except IDENTITY, can be used on the uniqueidentifier data type. and same as Guid id=Guid.NewGuid();
 

how to rename database in mssql

How to Rename Database in MsSql

 

Syntex

sp_renamedb '<Old DatabaseName>','<New DatabaseName>'

 

Example

sp_renamedb 'Amit','Amit_Kharbanda';
sp_renamedb 'Amit_Kharbanda','Amit' ;

how to check database size in mssql

How to check database size in MsSql

 

sp_helpdb <databaseName>

 

sp_helpdb Amit



 

how to create database in ms sql


How to Create Database in Ms Sql

----------------Create Database-------------

Create database Amit
on
(
name = 'Amit_master',
Filename = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Amit_master.mdf',size = 10mb
)
Log on(
name = 'Amit_log',
Filename = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Amit_log.ldf',size = 10mb
)

--------------------------OR--------------------------------------------


Create database Amit ;