Change Default Database in SQL Server Management Studio

Change your login name and database name and Execute following SP:

Exec sp_defaultdb @loginame='imsatasia\Rahul', @defdb='DBName'

OR

  • Go to “Object Explorer > Security > Logins”
  • Right click your Login and click on “Properties”
  • Under General Section, you can change Default Database value in drop down called “Default Database”

Set Default Database Name in SQL Server

How to Edit the Hosts File in Mac ?

Edit HOSTS file

  • Launch Terminal, found in /Applications/Utilities/ or launch through Spotlight
  • Type the following command at the prompt:
    sudo nano /private/etc/hosts
    
  • Enter the administrator password when requested, you will not see it typed on screen as usual with the command line
  • Once the hosts file is loaded within nano, use the arrow keys to navigate to the bottom of the hosts file to make your modifications
  • When finished, hit Control+O to save the file
  • Hit ENTER/RETURN to save changes to /private/etc/hosts
  • then hit Control+X to exit out of nano
  • Quit out of Terminal when finished


DNS Flush

Use following command in terminal:

dscacheutil -flushcache

Format Phone Number – SQL Server Function

SELECT dbo.CMN_FmtPhone('1234567891011')
Output: (123) 456-7891 Ext: 011

SELECT dbo.CMN_FmtPhone('1234567820')
Output: (123) 456-7820


CREATE FUNCTION CMN_FmtPhone
(
	@PhoneNumber varchar(15)
)
RETURNS varchar (15)
AS
BEGIN
	Declare @returnValue as Varchar(15)

	SELECT @returnValue =  
			CASE 
			WHEN LEN(LTRIM(RTRIM(@PhoneNumber))) = 10 
				THEN '(' + SUBSTRING(@PhoneNumber, 1, 3) + ')' 
						+ ' ' + SUBSTRING(@PhoneNumber, 4, 3) 
						+ '-' + SUBSTRING(@PhoneNumber, 7, 4) 
			WHEN LEN(LTRIM(RTRIM(@PhoneNumber))) > 10 
				THEN '(' + SUBSTRING(@PhoneNumber, 1, 3) + ')' 
						+ ' ' + SUBSTRING(@PhoneNumber, 4, 3) + '-' 
						+ SUBSTRING(@PhoneNumber, 7, 4) 
						+ ' Ext: ' + SUBSTRING(@PhoneNumber, 11, 5) 
			END

	RETURN @returnValue;

END

What Music Should You Listen to on THE JOB?

What Music Do You Listen to When You're Working?

Go the Fuck Home: Engineering Work/Life Balance By Pam Selle