DECLARE @PwdLen SMALLINT,
@Chr TINYINT,
@Password VARCHAR(20)
-- Seed
SET @Chr = RAND(DATEPART(ms, GETDATE())) * 0
SET @Password = ''
SET @PwdLen = 1
WHILE @PwdLen < 8
BEGIN
SET @Chr = RAND() * 62
SET @Password = @Password + CHAR(
CASE WHEN @Chr < 10 THEN @Chr + 48
WHEN @Chr BETWEEN 10 AND 35 THEN @Chr + 55
ELSE @Chr + 61
END)
SET @PwdLen = @PwdLen + 1
END
SELECT @Password [Password]
Technical Lead with 9+ years of IT experience in application system design and development using Microsoft technology. Worked in Onsite / Offshore setup. Excellent communication skills bridging Client Interaction and Team Management.
Monday, March 31, 2014
Generate a unique alphanumeric password using SQL
Wednesday, March 19, 2014
SQL statement which will give me all the days of a given month as individual rows
Hi friends,
I have searched a lot in Google and finally I found that its too easy to get the result. Check the query given below.
I have searched a lot in Google and finally I found that its too easy to get the result. Check the query given below.
DECLARE @month INT
DECLARE @year INT
SET @month=2
SET @year = 2016
SELECT CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) + Number 'date'
FROM master..spt_values WHERE type = 'P'
AND
(CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) + Number )
<
DATEADD(mm,1,CAST(CAST(@year AS VARCHAR) + '-' + CAST(@Month AS VARCHAR) + '-01' AS DATETIME) )
Labels:
MSSQL,
SQLEXPRESS
Location:
Bhubaneshwar, Odisha, India
Subscribe to:
Comments (Atom)
