SQL ServerScript3
SQL ServerScript3
Rename Table: If i want to modify the table name we have to use system procedure
Syntax: SP_RENAME 'OLDTABLENAME','NEWTABLENAME'
*/
sELECT * FROM FirstTable
SP_RENAME 'FirstTable','FirstTable_1'
/*
Rename Column: If i want to modify the column name we have to use system procedure
Syntax: SP_RENAME 'OLDTABLENAME.OLDCOLUMNNAME','NEWCOLUMNNAME'
*/
select * from FirstTable_1
/*
Alter: If you want to modify the structure of the table use ALTER command
1) Change the data type/Size for any column: If you want to change the
datatype/size to the existing column use ALTER command
Syntax: Alter table existingtablename alter column existingcolumnname newdatatype
size
*/
select * from FirstTable_1
--Note: If we want to see the table information select the table first and click on
ALT+F1
/*
Add Column: Add new column to the existing table use ALTER command
Syntax: Alter table existingtablename add newcolumnname datatype size
*/
select * from FirstTable_1
/*
Drop column: If we want to delete the column permenantly from the table use ALTER
command
Syntax: Alter table existingtablename drop column columnname
*/
Select * from FirstTable_1
/*
TRUNCATE: Delete all the records from the existing table use TRUNCATE
Syntax: Truncate table existingtablename
*/
Select * from [FirstTable]
/*
DML: The full form of DML is Data Manipulation Language. It will modify the
existing table data
DML commands are INSERT,UPDATE,DELETE
INSERT:If you want to insert new records to the existing table use INSERT command
*/
Select * from [FirstTable]