nav-left cat-right
cat-right
Random Articles
SQL Server REVERSE String... The SQL Server REVERSE string function can be quite useful if you need to...
dbo .. syntax and the def... In this post I’m going to discuss sql server’s dbo .. syntax....
Basic, Simple, Useful and... Topic: T-SQL SELECT (This article is about MS SQL Server) If you haven’t...
How to Loop using SQL Ser... In this post, describing how to loop using sql server cursor fetch...
SQL Server 2012 Date and ... Hi All.  I’ve put together an alphabetical reference list for SQL Server...
DECLARE and SET Variables... How many times do we as SQL developers have to declare and set variables?  I...

SQL Server CHARINDEX vs PATINDEX text search and p...

Podcast: Play in new window | Download (Duration: 6:04 — 5.6MB) The CHARINDEX vs PATINDEX question has been around for awhile now but to answer the question depends on your needs (why else would we have two keywords).  Both return a starting position number if your search text if found in a given text or character data parameter.  In this post I’ll give some quick examples of using both to perform the same task...

How to use SQL Server SET DATEFORMAT 2005, 2008, R...

The SQL Server SET DATEFORMAT statement sets the order in which the month, day and year are interpreted when looking at character strings.  Valid parameters are dym, dmy,  mdy, myd,  ydm, and ymd. Transact-SQL SET DATEFORMAT { dym | dmy | mdy | myd | ydm | ymd } 1 SET DATEFORMAT { dym | dmy | mdy | myd | ydm | ymd } There are some special cases where SET DATEFORMAT  isn’t supported or works differently depending on the...

T-SQL Insensitive Cursor 2005, 2008, R2, 2012, 201...

What is a t-sql insensitive cursor and what are the benefits?  The INSENSITIVE keyword on a cursor declaration tells SQL Server to create a temporary copy in tempdb and use it instead of referring to the actual table’s data when performing cursor operations.  What this means is that if an update or a delete to the actual table occurs while you are working with the cursor you won’t actually see it as the data will...

SQL Server REVERSE String Function with Examples 2...

The SQL Server REVERSE string function can be quite useful if you need to return a string or sequence in reverse order.  It can also be quite powerful when used in combination of other SQL keywords (CHARINDEX, RIGHT).  We’ll start by looking at some of the simple uses. [Sarcasm to follow] So say you’re and android and you’ve always dreamed of reversing your name and have gone your whole life up to this...

DECLARE and SET Variables in one line SQL Server 2...

How many times do we as SQL developers have to declare and set variables?  I recon that this occurs quite frequently, perhaps a million times a day…well, maybe not that many but it FEELS like it sometimes.  Prior to SQL Server 2008, we were forced to declare the variable in one statement and then set it in a following statement.  We got used to it but it was a constant annoyance for those of us to have better things to...

SQL Server 2012 Date and Time Functions

Hi All.  I’ve put together an alphabetical reference list for SQL Server 2012 Date and Time Functions which may come in handy when you’ve forgotten a particular keyword or just want to see what is available in one place without referencing books online.  There are 26 items in the list. @@DATEFIRST CURRENT_TIMESTAMP DATEADD DATEDIFF DATEFROMPARTS DATENAME DATEPART DATETIME2FROMPARTS DATETIMEFROMPARTS...

SQL Server 2012 String Functions List

Hi Everyone.  In this post I’m simply listing off all SQL Server 2012 string functions alphabetically for quick reference.  In all, there are 25 keywords in the list. SQL Server 2012 String Functions ASCII CHAR CHARINDEX CONCAT DIFFERENCE FORMAT LEFT LEN LOWER LTRIM NCHAR PATINDEX QUOTENAME REPLACE REPLICATE REVERSE RIGHT RTRIM SOUNDEX SPACE STR STUFF SUBSTRING UNICODE...

How to send a variable to a sql script from a batc...

Topic: sqlcmd variable from a batch file to a sql script Scripting is a powerful way to automate your systems.  It should come as no surprise to discover that SQL Server provides a way for developers to send in parameters to a sql script using a batch file via the sqlcmd utility (for SQL Server 2005 and later).  sqlcmd is a very versitile utility and I’ll be covering more of its uses in other posts but we’re...