SQL Tips and Tricks

Hello Everyone!!! Welcome to my Blog. I believe that knowledge should be shared with everyone and so I want to share all that I have learned in past 5 years of my professional experience. Currently I am working as a Senior Software Architect and Developer utilizing .NET technologies, SQL Server 2008, Dataware housing using Business Intelligence Tools like Analysis Services, Integration Services, Reporting Services, Web Services and XML.

Here is the first post of this BlogSpot which I thought could be helpful in certain scenarios that we get while working with data.

Scenario: If we have a table where we have following:

11111111 John123
22222222 Dave456


And we need to separate numbers from Name and get the following output

11111111 John
22222222 Dave

then following query can be useful

select EmployeeID,
REPLACE([Name],substring([Name],patindex(‘%[0-9]%’,[Name]),len([Name])),”) from tableNme where [Name] like ‘%[0-9]%’

Tags: , , ,

SQL Server