Hot answers tagged

6

Having a flag on the Stations table that indicates which station is local would be exactly how I'd handle this, presuming you don't have a billion stations. I'd likely call the column IsSourceStation or something, and make it a BIT value, that can accept NULL. I would mark the local station row as 1, and leave all other rows as NULL, since that won't take ...


5

Create a separate initializer that drops the database if it exists, then creates the database outside of any transaction handling code. If this fails for any reason, you could (probably) just fail the test right then and investigate why it failed. From MSDN: The CREATE DATABASE statement must run in autocommit mode (the default transaction management ...


3

Max Vernon's answer is correct in all but: No need for NULL in a bit value. It should be non-null, default 0. Querying a field which could be NULL adds overhead to your writing/reading/code maintenance. Basically the "correct" way to query a bit field is WHERE flag <> 0, if you might have NULL in the bit field you can still ask WHERE flag <> 0 (the ...


1

You just need to add a WHERE clause in the statement, like: where Date >= '2016-03-05': select v.Date, count(v.id) as co from volunter as v where v.Date >= '2016-03-05' group by v.Date order by v.Date ; Details may differ depending on the DBMS you use. For SQL Server for example, the safe format for the date and datetime types is 'YYYYMMDD', so ...


1

I've seen some options in .NET be different than the default SSMS options. Specifically, ARITHABORT was ON in SSMS, but in .NET it was OFF (the default value in the DB was off, where I assume .NET was pulling this from). This caused SQL Server to choose a vastly different (and terrible) plan in the .NET code. Can you verify the options (ANSI_NULLS, ...



Only top voted, non community-wiki answers of a minimum length are eligible