• Home
  • About
SQiLler

Get Firstname and Lastname from Fullname

Posted on July 12, 2014 by Hiram Romero
Firstname and Lastname

It is very common that sometime you will need to split a Fullname column into FirstName and Lastname columns, to do that you just need these functions:

GetFirstName

CREATE FUNCTION [dbo].[ufn_GetFirstName]  
(  
 @FullName varchar(500)  
)  
RETURNS varchar(500)  
AS  
BEGIN  
 -- Declare the return variable here  
 DECLARE @RetName varchar(500)  
  
 SET @FullName = replace( replace( replace( replace( @FullName, '.', '' ), 'Mrs', '' ), 'Ms', '' ), 'Mr', '' )  
  
 SELECT   
  @RetName =   
    CASE WHEN charindex( ' ', ltrim( rtrim( @FullName ) ) ) > 0 THEN left( ltrim( rtrim( @FullName ) ), charindex( ' ', ltrim( rtrim( @FullName  ) ) ) - 1 ) ELSE '' END  
  
 RETURN @RetName  
END

Continue reading “Get Firstname and Lastname from Fullname” »

Posted in SQL | Tags: firstname, fullname, functions, lastname, sql, TSQL | Leave a comment |

Reduce SSMS query tabs size

Posted on July 12, 2014 by Hiram Romero
sql big tabs

One of the most annoying things of SSMS is that the SQL query tabs are too big, this because it includes Filename + Server + Login User, and I really don’t see the point for that, because you can only visualize 3 or 4 tabs at a time before it starts to collapse the rest, see example:

Fortunately there is away to make the SQL query tabs smaller so you can see more at a time, and here is how:

sql big tabs

sql big tabs

Continue reading “Reduce SSMS query tabs size” »

Posted in SQL | Tags: query tab, reduce tab size, small query tabs, sql, sqlserver, SSMS, tabs, visualization | Leave a comment |

First things first …

Posted on July 12, 2014 by Hiram Romero
attach database 1

Before getting into details, you probably need the tools to start playing with SQL.

 

Get the tools

Head to Microsoft SQL Server site:

http://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/sql-server-express.aspx

Select download SQL Server 2014 Express

When Prompted choose “SQL Server Express with tools”.

 

Install

SQL Server with Management tools on your computer.

Continue reading “First things first …” »

Posted in SQL | Tags: create adventureworks, database, install sqlserver, sql | 3 Comments |
« Previous Page

Stack Overflow

profile for sqiller on Stack Exchange, a network of free, community-driven Q&A sites

Recent Posts

  • English dictionary with synonyms
  • Create your own SQL log
  • Drop table if exists
  • Replace a value in all tables
  • Share temp tables to other sessions
Follow on Bloglovin

Pages

  • About

Archives

  • June 2015
  • August 2014
  • July 2014

Categories

  • SQL (23)

WordPress

  • Register
  • Log in
  • WordPress
CyberChimps

CyberChimps

© SQiLler