Sql Server Interview Questions and Answers Part 1

By
1.) What is the use of SQL Server Management Studio ?                                                  
It is a software which is basically used for store and retrieve the data from the database.

2.) How to create a Database in sql server using command ?                                         

Create Database database_name
Ex.
Create Database School

3.) How to change existing database using command in sql server ?                        

Alter Database olddatabase_name modify Name=NewDatabase
Ex.
Alter Database school modify Name=college

4.) How to create a table in database using sql command ?                                         
create table table_name (column1 datatype,column2 datatype, column3 datatype)
Ex.   

create table student(sid int, sname varchar(30),sage int)

5.) How to Insert data in table using sql command ?                                                    
insert into table_name values(value1,value2,value3)
OR
insert into  table Name ( column1 , column2 , column3 )values( value1,value2,value3 )
OR
insert  table Name values( value1,value2,value3 )
Ex.
insert into student values(101,'vinod',22)
OR
insert into student(sname,sid,sage)values('neha',102,22)
OR
insert student values(103,'manoj',21)

6.) How to fetch all table values(rows) using sql command ?                                       
select * from table_name
Ex.
Select * from student

7.) How to fetch a specific column values from a table using sql command ?      
select column_name  from table_name
Ex.
Select sage  from student

8.) How to update an existing record in a table ?                                                               
Update table_name set column1=value,column2=value  where column3=value
Ex. 
Update student set sname='ram',sage=25  where sid=103

9.) How to delete all records(all rows) from a table  in sql server?                            
Delete from table_name
Ex.
delete from student

10.) How to delete a row from a table in sql server?                                   
Delete from table_name where column_name =value
Ex.
Delete from student where sid =105

1 comment:

Powered by Blogger.