Title Case Function for SQL Server

Title Case Function for SQL Server

As a SQL Server DBA, I realized that SQL Server has no function for Title Case, like the “initcap” function in Oracle. So I’ve made one that capitalizes the first letter of every word in a given text string:

create function initcap (@text varchar(4000))returns varchar(4000)asbegin	declare 	@counter int, 		@length int,		@char char(1),		@textnew varchar(4000)	set @text		= rtrim(@text)	set @text		= lower(@text)	set @length 	= len(@text)	set @counter 	= 1	set @text = upper(left(@text, 1) ) + right(@text, @length - 1) 	while @counter <> @length --+ 1	begin		select @char = substring(@text, @counter, 1)		IF @char = space(1)  or @char =  '_' or @char = ','  or @char = '.' or @char = '' or @char = '/' or @char = '(' or @char = ')'		begin			set @textnew = left(@text, @counter)  + upper(substring(@text, @counter+1, 1)) + right(@text, (@length - @counter) - 1)			set @text	 = @textnew		end		set @counter = @counter + 1	end	return @textend
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes