Archive
SQL Error – Index (zero based) must be greater than or equal to zero and less than the size of argument list
SQL Server version is “SQL Server 2012(SP2-CU15-GDR)(KB3194725) – 11.0.5676.0(X64)”.
An error occurred when you applied SQL Server 2012 Service Pack 3 to the current server(see attached image)
–> Summary Log
Overall summary:
Final result: The patch installer has failed to update the shared features. To determine the reason for failure, review the log files.
Exit code (Decimal): -2068774911
Exit facility code: 1201
Exit error code: 1
Exit message: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Start time: 2018-02-22 10:40:52
End time: 2018-02-22 10:41:22
Requested action: Patch
Solution:
There can be various reasons you might be getting this issue, like a failure of a previous installation of SQL server may corrupt the registry, and this registry corruption may initiate this issue.
There seems to be no direct fix to this, so try:
– Uninstalling all the patches, and re-install them in sequence.
– Or, uninstall the whole SQL Server completely and install fresh again.
What is ODS (Operational Data Store) and how it differs from Data Warehouse (DW)
I see lot of people discussing about ODS, and citing their own definitions and ideas about it. Some people also use the name as a synonym for a Data Warehouse or Factory Database. Thus, at times it becomes very difficult to tell or convince people while you are designing or architecting a DW/BI solution.
So, I thought to give some time to explain what actually an ODS is.
Simple definition: An Operational Data Store (ODS) is a module in the Data Warehouse that contains the most latest snapshot of Operational Data. It is designed to contain atomic or low-level data with limited history for “Real Time” or “Near Real Time” (NRT) reporting on frequent basis.
Detailed definifion:
– An ODS is basically a database that is used for being an interim area for a data warehouse (DW), it sits between the legacy systems environment and the DW.
– It works with a Data Warehouse (DW) but unlike a DW, an ODS does not contain Static data. Instead, an ODS contains data which is dynamically and constantly updated through the various course of the Business Actions and Operations.
– It is specifically designed so that it can Quickly perform simpler queries on smaller sets of data.
– This is in contrast to the structure of DW wherein it needs to perform complex queries on large sets of data.
– As the Data ages in ODS it passes out of the DW environment as it is.
–> Where does ODS fits in a DW/BI Architecture?
–> Classes of ODS (Types):
Bill Inmon defines 5 classes of ODS shown in image below:
– Class-1 ODS would simply involve Direct Replication of Operational Data (without Transformations), being very Quick.
– Whereas Class-5 ODS would involve high Integration and Aggregation of data (highly Transformed), being a very time-consuming process.
Difference between Temporary Table and Table Variable, which one is better in performance? – MSDN TSQL forum
–> Question:
Anyone could you explain What is difference between Temp Table (#, ##) and Table Variable (DECLARE @V TABLE (EMP_ID INT)) ?
Which one is recommended to use for better performance?
Also is it possible to create CLUSTER and NONCLUSTER Index on Table Variables?
In my case: 1-2 days transnational data are more than 3-4 Millions. I tried using both # and table variable and found table variable is faster.
Is that Table variable using Memory or Disk space?
–> My Answer:
Check this link to see differences b/w Temp Table & Table Variable.
TempTables & TableVariables both use memory & tempDB in similar manner, check this blog post.
Performance wise if you are dealing with millions of records then Temp Table is ideal, as you can create explicit indexes on top of them. But if there are less records then Table Variables are good suited.
On Tables Variable explicit index are not allowed, if you define a PK column, then a Clustered Index will be created automatically.
Ref Link.
SQL Tip – Disable or Enable all Indexes of a table at once
There are times when you need to DISABLE all Indexes of a table, like when there is a need to INSERT/UPDATE huge records in a table. As you have to INSERT huge records in a table the whole INSERT process could take more time to maintain/process Indexes on that table. Thus before inserting records its good to DISABLE all Non-Clustered indexes and post processing Re-Enable them.
USE [AdventureWorks2014] GO -- Disable Index -- Syntax: ALTER INDEX [idx_name] ON [table_name] DISABLE; ALTER INDEX [IX_Person_LastName_FirstName_MiddleName] ON [Person].[Person] DISABLE; GO -- Enable Index -- Syntax: ALTER INDEX [idx_name] ON [table_name] REBUILD; ALTER INDEX [IX_Person_LastName_FirstName_MiddleName] ON [Person].[Person] REBUILD; GO
Please note: to Enable you need to use REBUILD option, there is no ENABLE option just like DISABLE in above DDL statements.
–> Generate Queries of ALTER DDL scripts to:
– Disable all Indexes:
SELECT o.name, 'ALTER INDEX ' + QUOTENAME(i.name) + ' ON ' + QUOTENAME(SCHEMA_NAME(o.[schema_id])) + '.' + QUOTENAME(o.name) + ' DISABLE;' FROM sys.indexes i INNER JOIN sys.objects o ON o.object_id = i.object_id WHERE o.is_ms_shipped = 0 AND i.index_id >= 1 AND o.name = 'Person'
– Enable all Indexes:
SELECT o.name, 'ALTER INDEX ' + QUOTENAME(i.name) + ' ON ' + QUOTENAME(SCHEMA_NAME(o.[schema_id])) + '.' + QUOTENAME(o.name) + ' REBUILD;' FROM sys.indexes i INNER JOIN sys.objects o ON o.object_id = i.object_id WHERE o.is_ms_shipped = 0 AND i.index_id >= 1 AND o.name = 'Person'
Maintaining Uniqueness with Clustered ColumnStore Index | SQL Server 2014
Column Store indexes were introduced in SQL Server 2012 with a flavor of Non-Clustered index i.e. “Non-Clustered ColumnStore” index. However there is a big limitation that the underlying table becomes read-only as soon as you create one.
In SQL Server 2014 this behavior is unchanged and addition to this you can also create ColumnStore index as a Clustered index. And the good thing is that the table having “Clustered ColumnStore” index can also be updated. However there is one more big limitation here that there is no Clustered Key with this type if index, thus risking the Uniqueness in the table.
–> Here we will see this limitation and a workaround which can be used in some scenarios:
USE tempdb GO -- Create a simple table with 3 columns having 1st column to contain Unique values: CREATE TABLE dbo.TableWithCCI ( PKCol int NOT NULL, Foo int, Bar int ) GO -- Now create a "Clustered ColumnStore" index on this table: CREATE CLUSTERED COLUMNSTORE INDEX CCI_TableWithCCI ON dbo.TableWithCCI GO
Notice: While creating this index there is no provision to provided the “Clustering Key”, as this index includes all of the columns in the table, and stores the entire table by compressing the data and store by column.
On checking the metadata (by ALT+F1) of the table, you will see NULL under the index_keys column:
– Now let’s check this feature of absence of Uniquenes. We will enter 2 records with same value:
insert into dbo.TableWithCCI select 1,2,3 insert into dbo.TableWithCCI select 1,22,33 GO SELECT * FROM dbo.TableWithCCI GO
You will see 2 records with same duplicate value.
– Now, let’s create another Unique index to enforce this constraint:
CREATE UNIQUE INDEX UX_TableWithCCI ON dbo.TableWithCCI(PKCol) GO
We get an error that you cannot create more indexes if you have a Clustered ColumnStore index:
Msg 35303, Level 16, State 1, Line 25
CREATE INDEX statement failed because a nonclustered index cannot be created on a table that has a clustered columnstore index. Consider replacing the clustered columnstore index with a nonclustered columnstore index.
–> Workaround: As a workaround we can create an Indexed/Materialized View on top this table, with Clustering Key as the PK (1st column of the table/view):
CREATE VIEW dbo.vwTableWithCCI WITH SCHEMABINDING AS SELECT PKCol, Foo, Bar FROM dbo.TableWithCCI GO -- Delete duplicate records entered previously: DELETE FROM dbo.TableWithCCI GO -- Create a Unique Clustered Index on top of the View to Materialize it: CREATE UNIQUE CLUSTERED INDEX IDX_vwTableWithCCI ON dbo.vwTableWithCCI(PKCol) GO
– Now let’s try to enter duplicate records again and see if these can be entered or not:
insert into dbo.TableWithCCI select 1,2,3 insert into dbo.TableWithCCI select 1,22,33 GO
– As expected we get an error after we inserted 1st records and tried to insert the 2nd duplicate record:
(1 row(s) affected)
Msg 2601, Level 14, State 1, Line 48
Cannot insert duplicate key row in object ‘dbo.vwTableWithCCI’ with unique index ‘IDX_vwTableWithCCI’. The duplicate key value is (1).
The statement has been terminated.
–> Not sure why Microsoft has put this limitation of not maintaining the Uniqueness with these indexes. While using this workaround you need to consider this approach if possible. Like in some scenarios where the table is very big and there are frequent updates (INSERT/UPDATE/DELETES) this approach of maintaining another Indexed-View would be expensive. So this approach should be evaluated before implementing.
-- Final Cleanup: DROP VIEW dbo.vwTableWithCCI GO DROP TABLE dbo.TableWithCCI GO
I look forward in new versions of SQL Server to address this limitation.
You can also refer to MSDN BOL [here] for checking all limitations with ColumnStore Indexes.
[Update as of May-2015] with SQL Server 2016 you can make unique Clustered ColumnStore Index indirectly by creating Primary/Unique Key Constraint on a heap with a Non-Clustered Index, [check here].
Update: Know on ColumnStore Indexes as of SQL Server 2016:







