Skip to content

Instantly share code, notes, and snippets.

@gazlu
gazlu / view-large-nvarchar.sql
Created October 27, 2016 23:11
View large Nvarchar to debug in sql server
DECLARE BULKnvarchar nvarchar(max)
SELECT CAST('<data><![CDATA[' + @BULKnvarchar + ']]></data>' as xml)
-- use tools like 'http://coderstoolbox.net/string/#!encoding=xml&action=decode&charset=us_ascii' this
-- to decode the xml inside data element
@gazlu
gazlu / backup-localdb-database.bat
Created December 6, 2016 18:44
Backup SQL Server localdb database with sqlcmd
sqlcmd -E -S "(localdb)\v11.0" -q "BACKUP DATABASE <DBNAME> TO DISK='<DRIVE>:\<FOLDER_PATH>\<BACKUP_FILE_NAME>.bak'"
@gazlu
gazlu / ConfigurationTransformer.cs
Last active December 27, 2016 17:35
Configuration File transformer, easy to integrate config transformation with build systems
// You need to install 'Microsoft.Web.Xdt' from nuget ==> Install-Package Microsoft.Web.Xdt
using System;
using System.Reflection;
using Microsoft.Web.XmlTransform;
namespace ConfigTransformer
{
internal class Program
{
private enum ExitCode : int
@gazlu
gazlu / AppendChar.cs
Created February 27, 2017 16:51
Append Char before string
string name = "420";
var prefix = "0";
prefix += new string('0', 10 - name.Length - 1);
Console.WriteLine(zeros+name);
Console.WriteLine((zeros+name).Length);