Wednesday, July 1, 2009

Short-cuts In VS 2008?

There are 450 keyboard shortcuts in key VS 2005.
If you want to see all these then use following macro.
To Run Macro
1.Tools->Macro->Macro IDE OR ALT+F11
2.Expan MyMacro->Open Module1
3.Copy the following code
4.Run Macro (F5)

Check file c:\\Shortcuts.html

'Start Macro
Public Module Module1

Public Sub ListShortcutsInHTML()

'Declare a StreamWriter
Dim sw As System.IO.StreamWriter
sw = New IO.StreamWriter("c:\\Shortcuts.html")

'Write the beginning HTML
WriteHTMLStart(sw)

' Add a row for each keyboard shortcut
For Each c As Command In DTE.Commands
If c.Name <> "" Then
Dim bindings As System.Array
bindings = CType(c.Bindings, System.Array)
For i As Integer = 0 To bindings.Length - 1
sw.WriteLine("")
sw.WriteLine("" + c.Name + "")
sw.WriteLine("" + bindings(i) + "")
sw.WriteLine("")
Next

End If
Next

'Write the end HTML
WriteHTMLEnd(sw)

'Flush and close the stream
sw.Flush()
sw.Close()
End Sub
Public Sub WriteHTMLStart(ByVal sw As System.IO.StreamWriter)
sw.WriteLine("")
sw.WriteLine("")
sw.WriteLine("")</span><br /><br /><span style="color: rgb(51, 102, 255);"> sw.WriteLine("Visual Studio Keyboard Shortcuts")</span><br /><span style="color: rgb(51, 102, 255);"> sw.WriteLine("")
sw.WriteLine("")

sw.WriteLine("")
sw.WriteLine("

Visual Studio 2005 Keyboard Shortcuts

")

sw.WriteLine("")
sw.WriteLine("")
sw.WriteLine("")


End Sub

Public Sub WriteHTMLEnd(ByVal sw As System.IO.StreamWriter)
sw.WriteLine("
CommandShortcut
")

sw.WriteLine("")

sw.WriteLine("")
sw.WriteLine("")
End Sub

End Module

Wednesday, June 24, 2009

Delete all database without deleting constaints?

EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
GO

EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasForeignRef'') = 1
DELETE FROM ?
else
TRUNCATE TABLE ?
'
GO


EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO


EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasIdentity'') = 1
DBCC CHECKIDENT (''?'', RESEED, 0)
'
go