Recover database in “Restoring…” mode

Here is the sql to run when your database is in restoring mode.

restore database Budgets with recovery

You should know why your database is in restoring mode to begin with before running. For me, it’s typically because I left the db in no recovery mode after I restored a backup.

Posted in SQL | Leave a comment

Approximate total rows in SQL Server database

Here is a script that approximates the total rows in your SQL Server 2005+ database. It’s approximate because it comes off sys tables which are not updated constantly.

SELECT 
    [TableName] = so.name, 
    [RowCount] = MAX(si.rows) 
FROM 
    sysobjects so, 
    sysindexes si 
WHERE 
    so.xtype = 'U' 
    AND 
    si.id = OBJECT_ID(so.name) 
GROUP BY 
    so.name 
ORDER BY 
    2 DESC

I found this script at this site so all kudos to them.

Posted in SQL | Tagged | Leave a comment

Measure bandwidth between two computers on network

I found this tool called PCATTCP that will measure the speed between two computers on a network. It’s kinda like Iperf but for windows.

On the recieving computer you use this:

C:> pcattcp -r

And on the transmitting computer you use this:

C:> pcattcp -t 172.16.1.10

Here are what the results look like.

C:\Development>pcattcp -t 192.168.15.112
PCAUSA Test TCP Utility V2.01.01.13 (IPv4/IPv6)
  IP Version  : IPv4
Started TCP Transmit Test 0...
TCP Transmit Test
  Transmit    : TCPv4 0.0.0.0 -> 192.168.15.112:5001
  Buffer Size : 8192; Alignment: 16384/0
  TCP_NODELAY : DISABLED (0)
  Connect     : Connected to 192.168.15.112:5001
  Send Mode   : Send Pattern; Number of Buffers: 2048
  Statistics  : TCPv4 0.0.0.0 -> 192.168.15.112:5001
16777216 bytes in 0.289 real seconds = 56650.01 KB/sec +++
numCalls: 2048; msec/call: 0.145; calls/sec: 7081.252

It can also use IPv6.

Posted in Tips | Tagged , , | Leave a comment

Shout Out: Build Version Increment Add-In Visual Studio

Awesome plugin for Visual Studio. I wanted to automatically increment my version info in YYYY.MM.DD format and this makes it easy. You can find it on the CodePlex site.

Just make sure that after you configure it you save your project, otherwise the addin doesn’t kick in.

Download
Documentation

Posted in Visual Basic | Tagged | Leave a comment

Alias names in LINQ

Finally figured out how to set alias names in LINQ, and it’s easy.

Dim orgs = From p In db.Departments Select p.deporg, Name = p.deporg & " - " & p.depname Order By deporg

Name being the name of the concatenated field of p.deporg and p.depname.

Posted in SQL, VB.NET, Visual Basic | Tagged | Leave a comment