Category Archives: Uncategorized

Home / Uncategorized
48 Posts

SQL CMD tokens are replaced with their literal values prior TSQL parsing, so they can be used in places where a @ variable wouldn’t be permitted. Typically used for running queries within the SQL Server Management Studio, but such queries can be processed externally by calling SQLCMD.EXE (C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\SQLCMD.EXE). The literals are not scoped by GO statements like an @ variable and they can be re-defined later in the TSQL

Enable SQL CMD processing from the SQL Server Management Studio

EnableSQLCmdMode

Example SQL

Example C# – Using SQLCMD.EXE to run scripts

 

“Abstracted use case specific UML by implementing Java API used by the UI layer.”

The candidate could not explain what he meant by this statement and, since 2004, he has been periodically reminded of this. Yes, we hired him, yes it was the right choice. I am still receiving his paycheck garnishments.

“Please kindly do the needful”

The end of a cover letter from a person in India answering a posting for a local-only position. This became our team’s mantra for several years and is now a part of our regular language.

 

C#

Convert string array to string

result = HelloDoctorNameContinueYesterdayTomorrow
result2 = Hello, Doctor, Name, Continue, Yesterday, Tomorrow

Format Decimal as currency

result = $32.95

Format Decimal as string with N places

Optionally Running Debug Code

SQL

Generate Sequential Guids
arguably not the most commonly used capability, but here it is…

Print immediately to the Messages window when running queries in SQL Management Studio

Delete temp table if exists

SQL Server database stuck in “Restoring” state

Disable / Enable triggers and constraints for the database

Clear the cache without re-starting

Check if file exists using T-SQL
Note: The identity under which the SQL Server process is running will require permissions to read the file system. Right-click the folder/file from file explorer, from the “Security” tab, assign appropriate permissions to “NetworkService” (or whatever credential SQL Server is using). Don’t forget to remember not to forget to remember that the file system is seen from the perspective of the SQL Server!

Close all database connections
Using setvar in T-SQL

Other

Excel 2013 Cell Limit
Cell XFD1048576 is the max cell in Excel. It’s “right down” there.
That’s 16,383 columns x 1,048,576 rows.
excel-specifications-and-limits

Excel Guid Formula
=CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),”-“,DEC2HEX(RANDBETWEEN(0,65535),4),”-“,DEC2HEX(RANDBETWEEN(16384,20479),4),”-“,DEC2HEX(RANDBETWEEN(32768,49150),4),”-“,DEC2HEX(RANDBETWEEN(0,65535),4),DEC2HEX(RANDBETWEEN(0,4294967295),8))

Remove hiberfil.sys from a server
If it’s a Citrix VM, hibernation must first be enabled in the “firmware” by issuing the following command, and re-start the VM.

xe vm-param-add uuid=<your VM> param-name=platform acpi_s4=true

Run the command interpreter “Run as Administrator” and enter:
powercfg -h off

cropped-ThisJustIn.png

My ISP upgraded the site from MS Server 2003 \ IIS 6 to MS Server 2012 \ IIS 8. That’s great, but it broke my old BlogEngine. I’ll be re-creating [from backups] such gems as the largest Excel cell address, and the best ending comment for a SQL stored procedure.

They aren’t a great loss, but I miss them.