Category: SQL


T-SQL equivalent for NEXT_DAY() of ORACLE

I thought of creating a simple function for this operation, in T-SQL. Function Name: Next_Day Input Params: @FromDate - Date from which you wish to get the next day; @DayNumber - Day of week for which you wish to get the next day (6=>Saturday, 7=>Sunday) Operation: SELECT dbo.Next_Day(GETDATE(),6) //Returns the next Saturday (6) from today Function: Function body ...


Convert a comma separted list to a table in SQL

I thought of sharing this simple function that you can use for splitting a list or nvarchar(max) or anything that is coma separated and sent to DB, into a temp table. Reason: Performance is a bottle neck for us. As for that matter, for any SP executions. We cannot live with the IN operator. It ...


Encrypting and Decrypting passwords in SQL server

We have come across scenarios wherein highly sensitive information like passwords being stored in our database. It is a highly likely chance that during SQL Injection or unprecedented attacks, these table values gets exposed. I will explain here a simple means of encrypting, followed by decrypting the same password for user authentication. But let me ...