Skip to content

Tag: sql-server

Renaming index gives error Explicit @objtype id not recognised

I am trying to rename an index and getting an error: Error: Explicit @objtype ‘idx_FinData20’ is unrecognized. I can see both the table and index exist. Then what is the problem Answer First – your syntax is wrong. You need only two arguments, first should be table_name.old_name and second o…

Get fill rates in another table – SQL Server

I am trying to create a script to calculate the fill rates for each column in a table Data_table and insert it into a second table Metadata_table. The Data_table has 30 columns in it, and some columns have 100% data in them, and some have less than 100% (due to nulls). My code to calculate the fill rate looks…

Split a column in SELECT

I’m trying to get all records where I have a column concatenated with a :. The data stored in table as like this: I want to get below results by removing :extra from column in query: I’m not sure what should I do with my above query. Answer For SQL Server, you would do: You can find the columns us…

TSQL-ORDER BY clause in a CTE expression?

Can we use ORDER BY clause in a CTE expression? Error message: Msg 1033, Level 15, State 1, Line 14 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. Msg 102, Level 15, State 1, Line 25 Incorrec…

Heap big table with performance issues

I have a business case where I need to store all details about invoices from vehicle workshop (invoice number, dealer,vehicle number, peace, nature of service , …). I have more than 50 columns which are all selected in the same query. In my treatment I need to do some specific treatment in order to get …