Wednesday, December 16, 2020

Getting Local Date Time in SQL Server Database

When we work on cloud database, default function for getting current date time gives UTC date time. So for getting local date time we should create a scalar valued function using following script, so that it can be using seamlessly where ever needed..


SELECT CONVERT(DATETIME, GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'India Standard Time')

 

Above script will give India Standard Time DateTime.

Saturday, August 29, 2020

How to hold scroll position on autopostback?

 At the top of aspx code file, add the following:

MaintainScrollPositionOnPostback="true"

 

So the first line of index.aspx code file will look like as..

 
<%@ Page Title="index page" MaintainScrollPositionOnPostback="true" Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>

Saturday, April 25, 2020

Update Record with INNER JOIN SQL Server

General syntax for updating table by getting information from multiple tables..

UPDATE TableA
SET Col2 ..,
       ...
FROM TableA AS A
INNER JOIN TableB AS B ON B.Col1 = A.Col1
...
WHERE ...