Tuesday, 23 October 2012

SQL QUERIES



CREATE TABLE Person
(
LastName varchar(20),
FirstName varchar(20),
Address varchar(50))

sp_help Person

ALTER TABLE Person ADD City varchar(30)

SElect * from Person

ALTER table Person ALTER COLUMN firstname varchar(30)

INSERT INTO Person Values('Hetland','Camilla','Hegabakka 24','Sandness')
INSERT INTO Person Values('Pettersen','Kari','Storgt 20','Stavanger')
INSERT INTO Person (LastName,Address) values ('Rasmussen','Storgt 67')
Select * from Person
Update Person SET FirstName='Nina' WHERE LastName='Rasmussen'

Renaming a TABLE:
sp_rename 'Person', 'Persons'

alter table persons add year date

insert into persons (year) values ('1951')

select * from persons

delete from persons where YEAR ='1951-01-01'

update persons set year='1976-08-21' where firstname='Nina'


No comments:

Post a Comment