I've got a table with 9 million rows (just received it from our underwriting provider). 4 columns -- leadid (guid), RawLeadXML (nvarchar(max) that contain an xml doc in each row that is 2-3kb), LeadStatusID (int), and id (autonumber int, I just added this).
I am unable to run even a simple delete statement.
DELETE FROM Leads WHERE LeadID = '100a7927-5311-4f12-8fe3-95c079d32dd4'
I have tried to add an index to LeadID, but that times out.
CREATE NONCLUSTERED INDEX IX_Leads ON dbo.Leads(LeadID) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
My machine has 4 processors and 12 GB of RAM. Running Windows 7. SQL Server 2008 (I believe Developer Edition). How can I add an index to this table?
9M rows is not really that many. My guess is that in both situations, something is locking the table.
Check the table locks, and either close any processes that are locking the table, or kill the locks manually (if you're sure nobody else is using the database). There's a reasonably good script to show all locks here.