SQL – Concatenate

Background Across the various database systems, data Concatenation used to be everyman for himself. As in Oracle uses "|" as in:-   Transact SQL uses "+" as in:- DBA Pity the DBA he gets a query and he has to make changes to fit his\her platform. If it is a new code, he will appreciate … Continue reading SQL – Concatenate

Transact SQL :- String Concatenate using the Plus ( + ) Sign

Background I was doing a bit of code review. The developer cached data into a temporary table and wanted to review the fetched data.   Code Outline Temporary Table Temporary Table Create Populate data into the temporary table Concatenate String Display concatenated string Temporary Table Drop Temporary table SQL Output   Summary In Transact SQL, … Continue reading Transact SQL :- String Concatenate using the Plus ( + ) Sign

SQL and Bible Studies:- Books in each Genre

Background The Bible is a collection of books. One can categorize the books in so many different ways. In this post, we will use someone else work. He has categorized bible books into genres.   SQL The work avails a couple of database platforms. In this post, we will provide working samples for Transact SQL … Continue reading SQL and Bible Studies:- Books in each Genre

Transact SQL – Select And “FOR XML PATH”

Background A very, very good friend of mine runs a website where he posts quite a bit. Others post on the same site. Thankfully one of the persons that posted linked to his corporate website, as well. A good thing as I found a few interesting posts on the guest author's website. Transact SQL Transact … Continue reading Transact SQL – Select And “FOR XML PATH”

Transact SQL – Windowing Functions – Lag and Lead

Background Have used Windowing Functions for years now. But, never used Lag and Lead. Just thought it was too hard to layer on top of what was already hard for me.   Easy Finally today, I ended up dealing with something actually hard for me. A good man gracefully scaled it and he sprinkled in … Continue reading Transact SQL – Windowing Functions – Lag and Lead

SQLCMD:- Informational Message – “Changed database context to ….”

Background Let us quickly address a message pattern that is familiar to those who use sqlcmd. Message The message reads "Changed database context to ...." Source It is sourced to the presence of "use [database]" within a SQL command or file.   Remediation We have a bit of control over whether SQL Server emits the … Continue reading SQLCMD:- Informational Message – “Changed database context to ….”

Transact SQL – STRING_AGG – Error – “Multiple ordered aggregate functions in the same scope have mutually incompatible orderings.”

Background Working on some Transact SQL code yesterday. Ran into an error that was new to me. Error Error - Image Error - Text Sample Code The original code is a bit complex and sharing it will distract from this post's point. So here we go with sample code:-   Outline Original The original code … Continue reading Transact SQL – STRING_AGG – Error – “Multiple ordered aggregate functions in the same scope have mutually incompatible orderings.”

SQL Server Management Studio ( SSMS ) – Editor – Tabs and Spaces

Background When writing code, one gets to decide whether Tabs are kept as is; or have the editor automatically converts tabs to spaces.   SQL Server Management Studio ( SSMS ) Let us review SSMS Toolings as it relates to tabs and spaces.   Outline Editor Editing Choose Tabs or Spaces Selected Text Convert "Tabs … Continue reading SQL Server Management Studio ( SSMS ) – Editor – Tabs and Spaces

sqlcmd – Avail on MS Windows

Background Trying to a DOS Command batch on an MS Windows Box. Ran into an easy to correct error. Error Error Image Error Text   Remediation Outline Identify sqlcmd Download sqlcmd Install sqlcmd   Identify sqlcmd artifacts sqlcmd is available here. Images   Download sqlcmd Depending on the bitness of your OS, please choose (x64) … Continue reading sqlcmd – Avail on MS Windows

SQL Server – Transact SQL – Function – Unicode – Online Sample

Background Earlier this week I was helping a family member with an exercise. Transact SQL - Unicode His exercise involved using the Unicode function. Sample Googling landed me at the official Microsoft documentation for the Unicode Function. Documentation Unicode Transact SQL Link Microsoft Sample Microsoft Sample -01 Code Output     Microsoft Sample -02 Outline … Continue reading SQL Server – Transact SQL – Function – Unicode – Online Sample