Contents tagged with sql
-
Structuring UPDATE and DELETE queries so that they're a little bit safer
Quite often I've seen someone who wants to update a table, or delete rows from a table write a SELECT query to work out what data they want then separately write an UPDATE or DELETE query to …
-
TIL: Queries against linked servers... Be careful how you structure them!
The fact that a query across a SQL linked server (to another SQL server) is sometimes off-loaded to the remote server and sometimes not even when the entire query is operating on the remote data is …
-
The content of table variables is retained even when a transaction is rolled back
You learn something new every day! Thanks to the superbly detailed answer by Martin Smith on the question What's the difference between a temp table and table variable in SQL Server? at Database …
-
Link Dump
Another of those very lazy posts where I'm sharing links to content by other people, other content that I want to be able to refer back to in the future, admittedly!
Using LinqPad to open SQL CE 4.0 …
-
A quick and dirty query to find titles of Orchard blog posts that match criteria in SQL
I noticed earlier today that the number of "structured data" items Googles Webmaster Tools was reporting it had found on my website had dropped. Given that I'm continually adding new recipes (albeit …
-
Escaping identifiers in SQL when building up commands in C#
I answered a question on Stack Overflow recently about how to "encode" identifiers so that they aren't a source of SQL injection. As it's something I'm likely to keep "in the bank" I wanted to put up …
-
Using SQL Server CLR to add "earliest" and "latest" aggregate functions
Whilst there are undoubtedly very funky ways to achieve the same result, many moons ago I wrote a couple of SQL CLR aggregate functions for retrieving the earliest and latest values for a given …
-
What are the INFORMATION_SCHEMA views?
They're fantastically useful things which make it easy to access metadata in SQL Server in a (theoretically!) version agnostic manner. I've mentioned them (or similar) in SQL Server 2005: sysXXXX …
-
Finding the Foreign Keys for a table
For a while it's been driving me barmy, trying to obtain a list of Foreign Keys which reference a particular table. Below is the end result of my hunting. No doubt the code could be optimised, which …