Posts

Showing posts from December, 2016

Migrate SQLPrompt Snippets to VSCode

 I love snippets; love em. And I have a whole bunch in RedGate SQL Prompt. Now I want to be able to use those in VSCode as well, but boy do I dread having to retype all of them. Solution? Python! First arg is the path where your SQLPrompt snippets are Second arg is the directory where you want it to spit out a "sql.json" file with all your snippets. """ A script to translate sqlprompt snippet files to vscode formatted snippets """ import os import json import glob import io import argparse class SQLPromptPlaceholder :     """Represents the values of a SQLPrompt placeholder"""     def __init__ ( self , name , default_value ):         self . name = name         self . default_value = default_value class SQLPromptSnippet :     """Represents the content of a SQLPrompt snippet"""     @ staticmethod     def from_file ( filename ):         """Generates an instance fr

65335 Factorial

4597643839206139798834394184759123627791606542999044065434955006850467973888487369646743179134539924511398190750442203331208226857500559468414748729869089525893226953200795906903714832067821898907042261629562728969942119810014613789793907457345248217125680762482968429028968939623699293199693990805806760060083861925862374452062687514806778782280596095497203919252435260157455617162094230854524019588079203409134421869785206499300227993925963914895037051314258884162026719316085920116208512607769964983729984223110401900292801383099981541017532169507507681124468931938419338579838214678528787775049750261691770671966431262173069310693622479464912917015256994752289419408900432979739095957483066465378825509399001405061840629568788641562545240398182200693952819414127599029255936602043937937432667723682069384711335292603164311632276466199034110175386513375870207080042797827150133881229745175742324393298120067283358746413408824972192268005011421045053657631165662129060077428969674686340281707871260

Beware the Errors of SSIS

Image
SSIS is a bit of a touchy subject where I work, and the more I use it, the more I sort of understand why. While SQL Server is my background and I consider myself an expert in TSQL (not like, MVP level or anything), I don't do too much in SSIS. We have a home grown architecture which, in many ways, mimics functionality SSIS can do, and, for our purposes, usually works better and comes with fewer headaches. That said, there are some operations SSIS is simply hands down the best tool for the job. But I didn't come here to talk to you to day about when to or not to use SSIS. No dear reader, I come with a warning/complaint about how it surfaces error. The description of how it surfaces errors is "not very well". It's undoubtedly something you get better at teasing out over time, but I think largely because of the breadth of systems it needs to interact with, surfacing meaningful errors for specific stages can often seem to have absolutely nothing to do with the e

Big Crazy Linked Server Query

I got bored and was fiddling around with a statement I'd been doing manually in several steps to try to make it as easy to use (not read) and as quick as possible. The rundown is this:     I have a query I want to run which spans two databases.     The relevant schema for these two servers is as follows: -- Server 1     -- Has about 500m rows     create table dbo.orders     (         order_id varchar(55) primary key clusterd,         Data varchar(8000) -- just a placeholder to show that there's other stuff in here     )     -- Server 2     create table dbo.orderLog     (         order_id varchar(55) primary key clustered,         PayloadId int unique,         OtherData varchar(8000) -- Placeholder for other columns.        --Not that it matters, but this data is different than the data on server 1     )     -- Has about 20 million rows     create table dbo.events     (         RecordId int identity(1,1) primary key clustered,         PayloadId int,         TriggerDate