Showing posts with label recreate. Show all posts
Showing posts with label recreate. Show all posts

Friday, March 23, 2012

Rebuild Table Daily (sproc)

My goal is to recreate a table daily so that the data is updated. This could be a bad decision performance-wise, but I felt this was simpler than running a daily update statement. I created a stored procedure:

SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOCREATE PROCEDURE sp_CreatetblImprintPhraseASDROP TABLE tblImprintPhraseGOCREATE TABLE tblImprintPhrase(CustIDchar(12),CustName varchar(40),TranNoRelchar(15))GO
 However, I was looking to edit the stored procedure, changing CREATE to ALTER, but when I do so, I am prompted with: Error 170: Line 2: Incorrect syntax near "(". If I change back to CREATE, the error goes away, but the sproc cannot be run because it already exists. Any thoughts?
 

To be more specific, is there a proper method to make changes to a stored procedure that already exists? I assumed that swapping the CREATE statement for ALTER would be it, but it has been causing issues.

|||

Simply needed to read more about stored procedures. Batch processes in particular.

Tuesday, March 20, 2012

Rebuild clustered index and change filegroup

How can I rebuild my clustered index and change its filegroup, but don't want
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
Ranga
Try:
CREATE CLUSTERED INDEX IX_MyTable on MyTable (MyCol) WITH DROP_EXISTING ON
[MyFileGroup]
It will not drop and recreated the nonclustered indexes.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
..
"Ranga" <Ranga@.discussions.microsoft.com> wrote in message
news:20A15DB9-FEF8-426A-A2E2-8B2C69633E9F@.microsoft.com...
How can I rebuild my clustered index and change its filegroup, but don't
want
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
Ranga

Rebuild clustered index and change filegroup

How can I rebuild my clustered index and change its filegroup, but don't wan
t
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
RangaTry:
CREATE CLUSTERED INDEX IX_MyTable on MyTable (MyCol) WITH DROP_EXISTING ON
[MyFileGroup]
It will not drop and recreated the nonclustered indexes.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"Ranga" <Ranga@.discussions.microsoft.com> wrote in message
news:20A15DB9-FEF8-426A-A2E2-8B2C69633E9F@.microsoft.com...
How can I rebuild my clustered index and change its filegroup, but don't
want
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
Ranga

Rebuild clustered index and change filegroup

How can I rebuild my clustered index and change its filegroup, but don't want
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
RangaTry:
CREATE CLUSTERED INDEX IX_MyTable on MyTable (MyCol) WITH DROP_EXISTING ON
[MyFileGroup]
It will not drop and recreated the nonclustered indexes.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"Ranga" <Ranga@.discussions.microsoft.com> wrote in message
news:20A15DB9-FEF8-426A-A2E2-8B2C69633E9F@.microsoft.com...
How can I rebuild my clustered index and change its filegroup, but don't
want
to use the drop existing clause, which will drop and recreate all my
non-clustered indexes of that table ?
Thanks,
Ranga