Interview Questions → SQL SERVER → SQL Server Questionnaire I

SQL Server Questionnaire I











BEGIN TRAN
TRUNCATE TABLE Test_Match    
-- statement will return empty Test_Match table 
SELECT * FROM Test_Match    
ROLLBACK
--statement will return Test_Match table with original data
SELECT * FROM Test_Match  














--    declaring 2 temp table #Temp and #TempAddress
Create Table #Temp
(
    PK_ID int identity(1,1),
    sName Varchar(50)
)

Create Table #TempAddress
(
    PK_ID int identity(1,1),
    PersonID int,
    Address Varchar(100)
)

-- Inserting the value in both the tables
Insert Into #Temp Values('Karan')
Insert Into #Temp Values('Gupta')
Insert Into #Temp Values('Karan')
Insert Into #Temp Values('Karan')




PK_IDsName
1Karan
2Gupta
3Karan
4Karan


Insert Into #TempAddress Values(1,'Address1')
Insert Into #TempAddress Values(2,'Address2')
Insert Into #TempAddress Values(3,'Address3')




PK_IDPersonIDAddress
11Address1
22Address2
33Address3




select Address from #TempAddress a where a.PersonID in (select PK_ID from #Temp b where b.PK_ID = a.PersonID)






Address
Address1
Address2
Address3




Drop Table #Temp
Drop Table #TempAddress














Begin Transaction
update tblMessageCode Set MessageCode = 'tst'






































Create Proc #test
as
select * from <table_Name>




Create Proc ##test
as
select * from <table_Name>














PK_IDsNamesAddress
1Name1Address1
2Name2Address2






Create View v_tbl_Test
with schemabinding
as 
select PK_ID, sName, sAddress
from dbo.tbl_Test




Create Unique clustered index id_v_tbl_Test
on v_tbl_Test(PK_ID)















Posted By  -  Karan Gupta


Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250