Share Blog

Friday, May 23, 2014

Sql Server Interview Questions and Answers

1.) How to delete a specific record(a Row) from a table in sql server?                  
delete from table_name where column_name =value
Ex.
delete from student where id=1
2.) How to add a New Column in your Existing table using sql command ?          
alter table table_name add column_name datatype
Ex.
alter table student add address varchar(40)

3.) How to change the size of Existing column in a table ?                                            
alter table  table_name  alter column column_name datatype
Ex.
alter table student alter column address varchar(max)

4.) How to Drop the Existing column from a table ?                                                        
alter table  table_name  drop column column_name
Ex.
alter table student drop column saddress

5.) Is "INTO" Keyword is optional in insert statement ?                                               
Yes,We can insert the data in table without Into Keyword.

6.) Which keyword is always used for any changes in Database or table ?               
Alter

7.) How to change the column name in a existing table ?                                               
sp_rename 'table_name.oldcolumn_name','NewColumnName','column'
Ex.
sp_rename 'student.sage','Student_Age','column'

8.) How to change a existing table in sql server using command ?                            
sp_rename ' oldtable_name ',' Newtable_name ','object'
Ex.
sp_rename 'student','student_information','object'

9.) How to check the structure schema of any table in sql server ?                          
sp_help table_name
Ex.
sp_help student

10.) How to delete a table from database permanently ?                                              
Drop table table_name
Ex.
Drop table student

11.) How to remove a column name from a existing table. ?                                        
Alter table table_name drop column column_name
Ex.
Alter table student drop column sage

12.) Is Sql command is case sensitive?                                                                                  
No, We can use small latter or capital latter for any operation.

No comments:

Post a Comment