RSS

Category Archives: SQL Interview Questions And Answer

SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Day 3 of 31

 

Swap Value Between Two Row Of Columns In MS-SQL

Swap Value Between Two Row Of Columns In MS-SQL

Following Code Will Help you to Swap Value Between Two Row Of Columns In MS-SQL

 begin tran

declare @sum int

select @sum = sum(DisplaySeq)
from CustomCatalogForm
where CustomCatalogFormId in (1,2)

update CustomCatalogForm
set DisplaySeq = @sum - DisplaySeq
where CustomCatalogFormId in (1,2)

commit tran

I hope this helps, good luck!

 

Tags: , , ,

SQL Server – How to Find Total Number of Days in a Month

To Find out Total Number Of day in any month in Sql Server we have to write these Query :
Select datediff(day, GetDate(), dateadd(month, 1, GetDate()))
By using above query we can get total number of days for particular month.