Azure Data Studio – Cool Snippets

Azure Data Studio – Cool Snippets

Restore Snippets

If you are using Azure Data Studio you can export your current snippets by going to C:\Users\#CurrentUser#\AppData\Roaming\azuredatastudio\User\snippets\sql.json. You can navigate to the Roaming directory faster by running %appdata% in a Run Window (CTRL + R) this will take you to C:\Users\#CurrentUser#\AppData\Roaming.

Copying the old file to the new pc and overriding it will update your snippets.

Below is a sample list of all the snippets I use on a regular basis.

{

        "SELECT * FROM": 
	{
		"prefix": "sel",
		"body":"SELECT \n\t* \nFROM \n\t$0",
		"description": "SelectQuery"
	}

	,"Where": 
	{
		"prefix": "wh",
		"body":"WHERE\n\t$0",
		"description": "Where"
	}

	,"Distinct": 
	{
		"prefix": "dis",
		"body":"DISTINCT",
		"description": "DISTINCT"
	}

	,"Left Join": 
	{
		"prefix": "lj",
		"body":"LEFT JOIN\n\t",
		"description": "Left Join"
	}

	,"Update": 
	{
		"prefix": "upd",
		"body":"UPDATE\n\t$1\nSET\n\t$2\nWHERE\n\t$3",
		"description": "Update Statement"
	}

	,"Convert": 
	{
		"prefix": "cvn",
		"body":"CONVERT($1,$2)",
		"description": "Convert Statement"
	}

	,"Order By ASC": 
	{
		"prefix": "orda",
		"body":"ORDER BY\n\t$1 ASC",
		"description": "ORDER BY"
	}

	,"Order By DESC": 
	{
		"prefix": "ordd",
		"body":"ORDER BY\n\t$1 DESC",
		"description": "ORDER BY"
	}

	,"DECLARE DATE": 
	{
		"prefix": "decd",
		"body":"DECLARE @$1 DATE",
		"description": "DESCENDING"
	}

	,"DECLARE VARCHAR": 
	{
		"prefix": "decv",
		"body":"DECLARE @$1 varchar(500)",
		"description": "DECLARE VARCHAR"
	}

	,"WITH No LOCK": 
	{
		"prefix": "wnl",
		"body":"WITH(NOLOCK)",
		"description": "WITH NO LOCK"
	}

	,"GETDATE": 
	{
		"prefix": "gtd",
		"body":"GETDATE()",
		"description": "GETDATE()"
	}

	,"GROUP BY": 
	{
		"prefix": "grp",
		"body":"GROUP BY\n\t",
		"description": "GROUP BY"
	}

	,"COLLATE DATABASE_DEFAULT": 
	{
		"prefix": "col",
		"body":"COLLATE DATABASE_DEFAULT",
		"description": "COLLATE DATABASE_DEFAULT"
	}

	,"INNER JOIN": 
	{
		"prefix": "ij",
		"body":"INNER JOIN\n\t",
		"description": "INNER JOIN"
	}

	,"CASE WHEN": 
	{
		"prefix": "csw",
		"body":"CASE\r\tWHEN\n\t\t",
		"description": "CASE WHEN"
	}

	,"TOP 1000": 
	{
		"prefix": "t10",
		"body":"TOP 1000",
		"description": "TOP 1000"
	}

	,"DROP TABLE": 
	{
		"prefix": "drp",
		"body":"DROP TABLE\n\t",
		"description": "DROP TABLE"
	}

	,"GETTIME As Date": 
	{
		"prefix": "gtdt",
		"body":"CONVERT(Date,GETDATE())",
		"description": "GETTIME As Date"
	}

	,"Identity Insert On": 
	{
		"prefix": "idion",
		"body":"SET IDENTITY_INSERT $1 ON",
		"description": "GETTIME As Date"
	}

	,"Identity Insert Off": 
	{
		"prefix": "idiof",
		"body":"SET IDENTITY_INSERT $1 OFF",
		"description": "GETTIME As Date"
	}
}

Leave a Reply