Wednesday, November 27, 2013
Visual Studio 2012 comparison - F8 next difference keyboard shortcut
When comparing differences between 2 files in visual studio 2008 F8 will navigate to the next difference.
Windows Powershell Get-Content for monitoring log files similar to unix Tail
Windows Powershell Get-Content
Issue
For many developers testing or debugging often requires monitoring log files.
Closing and opening notepad gets tedious.
Soon, you have a bunch of notepads and you are note even sure what one is the current.
Power Shell to the rescue
1. Open windows powershell
2. enter this command
get-content logfile.log -Wait
3. You are now tailing your log file.
Issue
For many developers testing or debugging often requires monitoring log files.
Closing and opening notepad gets tedious.
Soon, you have a bunch of notepads and you are note even sure what one is the current.
Power Shell to the rescue
1. Open windows powershell
2. enter this command
get-content logfile.log -Wait
3. You are now tailing your log file.
Tuesday, November 26, 2013
Grant Execute to all stored procs in a database
This script gives execute rights to all stored procs for the [USERNAME]. It uses a cursor, but it works well
DECLARE procs CURSOR FOR SELECT [name]
FROM sys.objects
WHERE type IN('p','AF','FN')
DECLARE @name AS VARCHAR(250)
DECLARE @stmt AS VARCHAR(1000)
OPEN procs
FETCH NEXT FROM procs INTO @name
WHILE @@FETCH_STATUS=0
BEGIN
SET @stmt='GRANT EXECUTE ON '+@name+' TO [USERNAME]'
EXEC(@stmt)
PRINT @stmt
FETCH NEXT FROM procs INTO @name
END
CLOSE procs
DEALLOCATE procs
Wednesday, November 20, 2013
Visual Studio 2012 TFS offline
Coding with TFS integration into your solution with a unreliable connection can be frustrating.
Frustration- Waiting for TFS timeout is a production Killer
- Start editing a file
- Visual studio tries to check out the file from TFS
- You wait for the connection to timeout
Solution - Take Your Solution Offline
You can take your solution offline from source control. Out of the box the only way for visual studio to go offline is to
- Close and re-open the solution.
- hoping TFS is unavailable.
To the rescue is a visual studio plugin that will let you go offline any time you wish.
Happy Coding!
Tuesday, October 15, 2013
Great blog post - maintaining software
A favorite past time of most developers is to call your fellow geek over and have them check out some really smelly piece of code. I am sure it even happens to my code from time to time, hopefully not to often.
Friday, May 31, 2013
Remote Desktop to Hyper-V on Windows 8
So the virtual machine connection inside of hyper-v stinks. Limited resolution choices and no copy/ past functionality. None of the niceties of remote desktop. As a developer a very difficult environment to work in.
So I spent some time trying to get it to work, and found this solution
https://stoknes.sharepoint.com/runesblog/Lists/Posts/Post.aspx?ID=12&mobile=0
I followed the instructions, did not change my default ip address.
Make sure you put the address in your remote desktop window as <your_virtual_machine's_name>.mshome.net
So I spent some time trying to get it to work, and found this solution
https://stoknes.sharepoint.com/runesblog/Lists/Posts/Post.aspx?ID=12&mobile=0
I followed the instructions, did not change my default ip address.
Make sure you put the address in your remote desktop window as <your_virtual_machine's_name>.mshome.net
Wednesday, May 15, 2013
4 Steps to take a SQL SERVER Database out of Single User Mode
Recently my database got stuck in single user mode and I could not open it to change into multi-user.
Steps 1-4 will show you how it works. Step 5 shows how to do it with one script
I used the scripts below to fix this.
This is in SQL Server management studio with SQL Server R2
1. Find My Database id
Steps 1-4 will show you how it works. Step 5 shows how to do it with one script
I used the scripts below to fix this.
This is in SQL Server management studio with SQL Server R2
1. Find My Database id
SELECT db_id('MyDB')
2. Find the session id that was using the single user mode, using the dbid returned from step 1
SELECT SPID,DBID,*
FROM SYSPROCESSES
WHERE DBID NOT IN(1,2,3,4)
AND SPID>50
AND SPID<>@@spid
AND dbid=[DBID]
3.Kill the session using the SPID from step 2
KILL 999
4.put the database back into multi-user mode
Below is a script to do it all at once. ALTER DATABASE MyDatabase
SET MULTI_USER
Now you can get back into your database,
DECLARE @DBID AS INT
DECLARE @SPID AS INT
DECLARE @SQL AS NVARCHAR(MAX)
SELECT @SPID=SPID
FROM SYSPROCESSES
WHERE DBID NOT IN(1,2,3,4) AND SPID>50 AND SPID<>@@spid AND dbid=db_id('MyDatabase')
IF @SPID!=NULL
BEGIN
SELECT 'Nothing to delete'
END
ELSE
BEGIN
SET @SQL='KILL '+CONVERT(VARCHAR,@SPID)
EXEC sp_executesql @SQL
END
ALTER DATABASE MyDatabase
SET MULTI_USER
To Format this TSQL I Used http://www.ubitsoft.com/products/t-sql-beautifier/ it worked great
Subscribe to:
Posts (Atom)