Scripts

Technical Article

Use TSQL for Drawing

This is an algorithm from the september 1986 issue of Byte Magazine, in an article called Abstract Mathematical Art. It borrows from Tim Conways Game of Life to represent an algorithm by which a series of numerical values can attempt to replicate itself. It is deeply steeped in the philosophy of Caos Theory and Evolution, […]

1 (1)

You rated this post out of 5. Change rating

2006-08-28 (first published: )

326 reads

Technical Article

Alphanumeric and Special Character Validation

Inspired in the script submited by ramesh_kondaparthy , this is a set oriented solution for the same problem.Parameters: 1) @InputString varchar(25)Accepts the string, which we need to validate 2) @Type int = 0 validate the string for only alphanumeric charactersi.e Allows characters between [A-Z] ,[a-z] and [0-9] = 1 validate the string for alphanumeric and […]

You rated this post out of 5. Change rating

2006-08-22 (first published: )

3,979 reads

Technical Article

Change to readable date format

Trigger to insert date into table in the form of01/01/00 12:00:00instead of SQL standard date format2000-01-01 12:00:00.000This allows easily comparing to or updating based onOracle date formats or a readable format for the web.triggername - name of the triggerTABLENAME - name of the table that trigger is created onCOLUMNNAME - name of column in TABLENAME […]

You rated this post out of 5. Change rating

2006-08-21 (first published: )

472 reads

Technical Article

relatively simple mode, median, mean

Here's a sample script to help you get some generic mode, median, and mean statistics for something. In my example, I'm getting the number of days something takes to start and stop some task. The idea is that I'd have a fairly short list of jobs, and record would record the job id, and start/stop […]

You rated this post out of 5. Change rating

2006-08-17 (first published: )

1,059 reads

Technical Article

Function to return the SQL Build Number

This function returns the SQL Build Number as a nvarchar(20) string. i.e. '8.00.760' @@Version is great, but super long, and the formatting of the string has changed over the years. This helps me find out what build of SQL I'm working on in a quick and efficient manner. The script includes the drop statement as […]

5 (1)

You rated this post out of 5. Change rating

2006-08-09 (first published: )

1,015 reads

Technical Article

Function to return the SQL Version Number

This function returns the SQL Build Number as an int. i.e. 7, 8, or 9. @@Version is great, but super long, and the formatting of the string has changed over the years. This helps me find out what version of SQL I'm working on in a quick and efficient manner. The script includes the drop […]

You rated this post out of 5. Change rating

2006-08-08 (first published: )

1,229 reads

Technical Article

Bulk Insert WMIC output to table w/ xp_cmdshell

This is an example of retrieving WMIC results using the xp_cmdshell proc, and inserting the results into a table.Specifically, this script retrieves disk info from the LogicalDisk class, but WMIC provides thousands of other properties. WMIC does require it be ran from a Windows 2003 server, but can query other Windows 2000 servers when executed […]

2 (1)

You rated this post out of 5. Change rating

2006-08-04 (first published: )

783 reads

Technical Article

UDF to return Years, Months & Days between 2 dates

There are two UDF's included here.The first one will return the number of Years, Months and Days between a Start and End date.The second one will return either Years, Months or Days which makes it much easier to include in a select.If you know of or find a better/faster way to do this, then please […]

You rated this post out of 5. Change rating

2006-08-01 (first published: )

171 reads

Technical Article

Handle Divide by Zero in SQL Reporting Services

Out of the box, Reporting services does not handle divide by zero conditions gracefully. There are plenty of posting on how to use the IIF() function to accomplish this, with some rather horrific looking code. In order to simplify the coding process and make the resulting expressions readable by a mere mortal, I wrote the […]

4.5 (14)

You rated this post out of 5. Change rating

2006-07-28 (first published: )

3,977 reads

Blogs

Webcast Tomorrow on SQL Server Disaster Recovery

By

Tomorrow, November 19, 2024, at 1 PM EST, I'm giving a webcast on SQL...

SQL Server Quickie #48 – Azure SQL Managed Instance

By

Today I have uploaded SQL Server Quickie #48 to YouTube. This time I’m talking...

Spark Connect Dotnet November 2024 Where are we?

By

All Spark Connect Posts Introduction There have been quite a few changes in the last...

Read the latest Blogs

Forums

Generating (semi-)fake purchase data

By pietlinden

I know how to generate fake data (thanks to Jeff Moden's articles!)... the problem...

Export database and tables no table data

By HeftSteady

Trying to move a database from one sql server instance to another on separate...

Package to Project model conversion

By blom0344

Hi All, With previous customer range we were always required to work in the...

Visit the forum

Question of the Day

What's the Ceiling?

What do I get as the results from this code?

SELECT CEILING (999.999), CEILING (-999.999);

See possible answers