Tag: stored procedure
DataFlow in SSIS and OLE DB Command
by mysticslayer on Jul.11, 2009, under Programming, sql server, SSIS
I’ve been working for the first time with a DataFlow of updating data in a SQL Database with SSIS. The only problem is that a colleaque did made it, but he forget something with it. After reading some documentation about the DataFlow in SSIS and the using of a OLE DB command to execute a Stored Procedure I came to a certain problem.
The problem is that a OLE DB Command can execute a Stored Procedure, but the error handling is really a issue. Why, you can give a output parameter with it, but for some reason it doesn’t work well. The question is why they didn’t use a SQL Task to execute a Stored Procedure. Now I’m searching why my stored procedure isn’t fired well.
Well the problem is that the stored procedure contains a error handling not supported by the OLE DB Command. And when you have error handling handled by you SSIS you get a Error Number 0 returned. So your searching for a problem with Error number 0? That’s really crap. So I get rid of the Error handling in the stored procedure, and well the funny thing is that the stored procedure really is fired well and with filled parameters. But another problem is now that there are not enough parameters filled to execute the Stored Procedure properly.
So I have to search for that issue to solve the problem….
Stored procedure for Reindexing and Update Stats
by mysticslayer on May.09, 2009, under Programming, sql server
Well I was searching for a Stored Procedure that you can use for reindexing and updating stats, etc.
I didn’t find any nice procedures that gave me the solution I needed, so I’ve read some posts by google, and made the following procedure 🙂
This procedure will loop through all the tables and all indexes and shall Reindex them. When every index on every table is reindexed it will update all the stats on the database.
Of course you can choose to change the fill index from 80 to any other valid percentage.
-
-
CREATE PROCEDURE spUtil_ReIndexDatabase_UpdateStats
-
AS
-
BEGIN
-
— SET NOCOUNT ON added to prevent extra result sets from
-
— interfering with SELECT statements.
-
SET NOCOUNT ON;
-
DECLARE @MyTable VARCHAR(255)
-
DECLARE myCursor
-
CURSOR FOR
-
SELECT table_name
-
FROM information_schema.tables
-
WHERE table_type = 'base table'
-
OPEN myCursor
-
FETCH NEXT
-
FROM myCursor INTO @MyTable
-
WHILE @@FETCH_STATUS = 0
-
BEGIN
-
PRINT 'Reindexing Table: ' + @MyTable
-
DBCC DBREINDEX(@MyTable, '', 80)
-
FETCH NEXT
-
FROM myCursor INTO @MyTable
-
END
-
CLOSE myCursor
-
DEALLOCATE myCursor
-
EXEC SP_UPDATESTATS
-
GO
-
END