Robin Hames

Hints, tricks and tips relating to MS SQL Server and .NET
posts - 14 , comments - 45 , trackbacks - 0

November 2008 Entries

SQL server script to generate CREATE INDEX commands
This script generates the “CREATE INDEX” scripts for a SQL Server database: set nocount on declare @index table ( object_id int, objectName sysname, index_id int, indexName sysname, fill_factor tinyint, allow_row_locks bit, allow_page_locks bit, is_padded bit, indexText varchar(max), indexTextEnd varchar(max) ) declare @indexColumn table ( object_id int, index_id int, column_id int, index_column_id int, max_index_column_id int, is_descending_key bit, is_included_column bit, columnName varchar(255), ......

Posted On Friday, November 21, 2008 12:30 PM | Comments (0) |

SQL Server datetime - getting the date part only
I am always forgetting the format for using DATEADD and DATEPART functions to get just part of a SQL Server datetime (e.g. just the date), so I am posting it here so I’ll always know where to find it. declare @date datetime set @date = getdate() select @date, dateadd(day, datediff(day, 0, @date), 0) ......

Posted On Wednesday, November 19, 2008 3:17 PM | Comments (1) |

Powered by: