Monthly Archives: September 2010
Cropper. Free SnagIt alternative with source code – worth a look… Does what you wish Print Screen would do.
In the past I posted a blog about the use of SCOPE_IDENTITY() instead of @@identity because the SCOPE_IDENTITY() returns the key created in the context of the scope of the currently executing script, which is likely what you intended, rather than the last key inserted on the connection you are using.
Recently I was using a stored procedure to insert a record and I used
to return the key (defined as a bigint) of the newly created record. I then used the .net C# code:
long key = command.ExecuteScalar();
to get the value returned. This turned out to actually return a decimal type, which surprised me. It turns out that SQL Server will sometimes convert a bigint to a NUMERIC type and thus you really need something more like this:
long key = Convert.ToInt64(command.ExecuteScalar());
The need to do this surprised me, but I was reassured that this is a normal treatment of a bigint key and conversion is necessary.