Querying Microsoft SQL Server

Blog Post

Generate Random Passwords using T-SQL

Use following script to generate random Passwords
DECLARE @id int,@list varcharSET @list ='abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789.,-_!$@#%^&*'selectreplace(SUBSTRING(CONVERT(varchar(255),NEWID()),8, 8),'-','')as RANDOM

Example:
Suppose you have a table tblUser with columns[id],[userid],[password].
CREATETABLE [dbo].[tblUser](     ...

2013-02-12

4,849 reads

Blog Post

Frequently asked SQL Server Queries

Data to test:
CREATETABLE [dbo].[emp](      [emp_id]
[nchar](10)NULL,      [emp_name]
[nchar](10)NULL,      [salary]
[int] NULL)ON [PRIMARY] insert emp( emp_id,emp_name,salary )  select'1','ABC',-20000 insert emp( emp_id,emp_name,salary )  select'2','XYZ',-5000 insert emp( emp_id,emp_name,salary )  select'3','PQR',-7800 insert emp( emp_id,emp_name,salary...

2013-02-04

748 reads

Blogs

Speaking at the 2025 PASS Data Community Summit

By

I will be back in Seattle this year attending the 2025 PASS Data Community...

The Book of Redgate: Motivation

By

Another of our values is this: Motivation isn’t about carrots and sticks. Constant oversight...

A Six Week Break

By

Today is my last day of work for six weeks. I start my sabbatical...

Read the latest Blogs

Forums

Three Times a Day

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Three Times a Day

SUM([value]) and highest record type

By Pete Bishop

Given a record mapping table: Id Initial Updated 1 1 2 2 3 4...

should i expect data types in task->export data from ssms?

By stan

Hi i recently exported a number of "to be purged resultsets " to .tsv's. ...

Visit the forum

Question of the Day

Multiple Defaults

In my SQL Server 2022 database, I run this code:

ALTER TABLE dbo.OrderHeader 
ADD ModifiedStamp DATETIME CONSTRAINT df_Created_Getdate DEFAULT GETDATE()
GO
I decide I need to add auditing to another table and run this:
ALTER TABLE dbo.Tracker
ADD Created DATETIME CONSTRAINT df_Created_Getdate DEFAULT GETDATE()
GO
What happens with these statements?

See possible answers