T-SQL

Technical Article

XML Encode UDF

  • Script

I routinely need to retrieve and package query result sets in an XML package.  The built in functions supported by SQL Server 2000 are effective, but are often more of a pain than a help.  This routine can be used in a simple select statement to XML encode the contents of a column during the […]

You rated this post out of 5. Change rating

2003-10-14

236 reads

Technical Article

Haversine Calculation in User Defined Function

  • Script

Uses the haversine formula to calculate distance between 2 long / lat points.  This can be used with a zip code / lat and long table that are available from the census bureau or post office.The @R can be tweaked dependent on what gives you the best result (its the radius of the earth, fluctuates […]

You rated this post out of 5. Change rating

2003-09-25

742 reads

Technical Article

Get Column Lists script

  • Script

This is a script like Column_Gitter by Rick Bolin (RickInMesa), it differs in the fact that it does not use cursors, it optionally adds the table name, it handles UDDT (User Defined Data Types) properly, and handles the new SQL Server 2000 datatypes.Usage: Open this script in QA, Change QA to the desired Database, Edit […]

5 (1)

You rated this post out of 5. Change rating

2003-09-24

716 reads

Technical Article

Replace Mult Instances of a Pattern in a String

  • Script

This function takes a pattern to be searched for, a string that the pattern will be removed from and a flag to determine whether all instances of the pattern should be removed.This is sort of an expanded version of a function I wrote to remove multiple spaces from a string.

You rated this post out of 5. Change rating

2003-08-20

177 reads

Technical Article

Column_Gitter Part Deux

  • Script

This script is similar to Column_Gitter.  I noticed this script and wanted to present the same output without the use of cursors.  Both scripts work well and produce the same results.  This little utility comes in handy if you do a lot of SQL coding. Given a table name, it'll return four results: The names […]

You rated this post out of 5. Change rating

2003-08-14

91 reads

Technical Article

ISINTEGER function

  • Script

This function is similar to the ISNUMERIC native function, but tests for a valid integer.  ISNUMERIC can return false positive results when testing for a valid integer.  For example this select returns a value of 1 (true):select isnumeric('3d8')For 6.x and 7.0, you can easily convert it to a procedure.

5 (3)

You rated this post out of 5. Change rating

2003-08-14

2,912 reads

Blogs

Sic Transit Gloria Community

By

When Covid took out the PASS organization, I had someone say to me, “Well,...

DATEADD Truncates the Number Parameter: #SQLNewBlogger

By

This was an interesting thing I saw in a Question of the Day submission....

Our SQL Server is Slow! What Do I Do First?

By

Don’t Panic! It’s a vague but common complaint, frequently with no additional details. Before...

Read the latest Blogs

Forums

Dynamic T-SQL Script Parameterization Using Python

By omu

Comments posted to this topic are about the item Dynamic T-SQL Script Parameterization Using...

Error when trying to enable cdc . Could not update the metadata

By pamkagel

Server and db in SQL SERVER 2019. I have multiple tables that are enabled...

Parameter dataset doesn't show results in dropdown

By NineIron

My report has been working fine. Now, when I run the report, the Location...

Visit the forum

Question of the Day

A Strange Choice

What is returned when I run this code in SQL Server 2022?

CREATE TABLE CatIndex
( indexval VARCHAR(20)
)
GO
INSERT dbo.CatIndex (indexval) VALUES ('1'), ('2'), ('3')
GO
SELECT CHOOSE(indexval, cast('2025-01-01' AS DATE), CAST('2025-02-01' AS DATE), CAST('2025-03-01' AS DATE))
FROM dbo.CatIndex AS ci

See possible answers