Author name: EkAdmin

TSQL : Using GOTO Line number Type command

The GOTO statement in T-SQL allows you to transfer control to a labeled line of code within a stored procedure or a batch. The labeled line is identified by a unique label name followed by a colon (:). Here is an example of how you can use the GOTO statement in T-SQL:

DECLARE @Value INT = 1

IF @Value = 1
BEGIN
PRINT ‘Value is 1’
GOTO EndOfCode
END

PRINT ‘Value is not 1’

EndOfCode:
PRINT ‘End of code’

In this example, the IF statement checks if the value of the @Value variable is equal to 1. If the value is 1, the PRINT statement outputs “Value is 1” and control is transferred to the labeled line of code identified by EndOfCode using the GOTO statement. The execution continues from that line and the PRINT statement outputs “End of code”.

It is important to note that the use of the GOTO statement is generally discouraged in T-SQL programming as it can make the code difficult to understand and maintain. It is recommended to use structured control flow statements such as IF, WHILE, and FOR instead of GOTO.

TSQL : Chk If Valid JSON

You can use the ISJSON function in T-SQL to check if a string is a valid JSON string. The ISJSON function returns 1 if the input string is a valid JSON string and 0 if it is not. Here is an example of how you can use the ISJSON function:

DECLARE @Json NVARCHAR(MAX) = ‘{
“id”: “2”,
“body”: “Media Msg”
}’

IF ISJSON(@Json) = 1
BEGIN
PRINT ‘Valid JSON’
END
ELSE
BEGIN
PRINT ‘Invalid JSON’
END

In this example, the ISJSON function is used to check if the string stored in the @Json variable is a valid JSON string. If the string is valid, the PRINT statement outputs “Valid JSON”. If the string is not valid, the PRINT statement outputs “Invalid JSON”.

VB6 : Read Date Time Format Of Login User

Option Explicit

Private Declare Function GetLocaleInfo Lib “kernel32” Alias “GetLocaleInfoA” (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Const LOCALE_USER_DEFAULT As Long = &H400
Private Const LOCALE_SSHORTDATE As Long = &H1F

Private Sub Form_Load()
Dim sDateFormat As String
Dim lRet As Long

sDateFormat = Space$(255)
lRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, sDateFormat, Len(sDateFormat))
If lRet > 0 Then
sDateFormat = Left$(sDateFormat, lRet – 1)
MsgBox “The short date format is: ” & sDateFormat
Else
MsgBox “Failed to retrieve the short date format.”
End If
End Sub

TSQL-Generate Unique String (6 Digit)

declare @UserCode nVarChar(6),@NextID Int=2

SET @UserCode =
RIGHT(‘000000’ +
CAST(
ABS(CAST(CAST(NEWID() AS BINARY(8)) AS BIGINT)) % 1000000
AS VARCHAR(6)
),
6);

Print @Usercode

DECLARE @rtnStr nVarChar(6)

set @rtnStr= RIGHT(‘000000’ +
CAST(
ABS(CAST(CAST(NEWID() AS BINARY(8)) AS BIGINT)) % 1000000
AS VARCHAR(6)
),
6);

TSQL-Split String Using CharIndex

DECLARE @btnID nVarChar(15)=’10_2′;
DECLARE @QID INT, @AID INT;

SET @QID = CAST(LEFT(@btnID, CHARINDEX(‘_’, @btnID) – 1) AS INT);
SET @AID = CAST(RIGHT(@btnID, LEN(@btnID) – CHARINDEX(‘_’, @btnID)) AS INT);

—————————————————————————–
DECLARE @strThis nVarChar(100) = ‘a,b,c,d’;
DECLARE @splitValues TABLE (Value nVarChar(100))

IF (SELECT COUNT(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[STRING_SPLIT]’)) > 0
BEGIN
INSERT INTO @splitValues
SELECT value FROM STRING_SPLIT(@strThis, ‘,’)
END
ELSE
BEGIN
DECLARE @pos INT = CHARINDEX(‘,’, @strThis)
DECLARE @val nVarChar(100)

WHILE @pos > 0
BEGIN
SET @val = LEFT(@strThis, @pos – 1)
INSERT INTO @splitValues
VALUES (@val)

SET @strThis = RIGHT(@strThis, LEN(@strThis) – @pos)
SET @pos = CHARINDEX(‘,’, @strThis)
END

INSERT INTO @splitValues
VALUES (@strThis)
END

SELECT * FROM @splitValues

Single Page ASPX File

<%@ Page Language="C#" AutoEventWireup="true" %>



Single Page ASPX without Code Behind




Scroll to Top