Indexing using UPPER function in SQL Server - sql-server

I am trying to create the indexes using the liquibase using following query in SQL Server.
CREATE NONCLUSTERED INDEX LASTNAME_IDX ON EMPLOYEE(UPPER(LAST_NAME));
But I am getting the error while running the liquibase. It works fine in oracle. Let me know if there a way I can create the index in SQL Server

SQL Server does not support function indices, which Oracle does support. One workaround here would be to create a computed uppercase column, and then index that:
ALTER TABLE EMPLOYEE ADD LAST_NAME_UPPER AS UPPER(LAST_NAME);
CREATE NONCLUSTERED INDEX last_name_idx ON EMPLOYEE(LAST_NAME_UPPER);

Related

How can I add columnstore index to existing tables in SQL Server?

I always use this method, which is "existing table right click script table as > clipboard" when I create a new table in SSMS. Today, I realized this method doesn't create columnstore index.
I realized that this method doesn't add "columnstore index" to script. Shortly, any table doesn't have csi. Therefore I have to add csi to existing tables in SQL Server. What is the fastest way to add csi to existing tables?

Replace a clustered index with a non-clustered one on primary key using SQL Server Management Studio UI without generating a script

When you designate a column as the primary key in SQL Server Management Studio, it automatically creates a clustered index on the column. How do you replace the index with a non-clustered one using the SQL Server Management Studio user interface, but without generating or writing a script to drop the index and create the non-clustered one?
I know how to do it with a script (ALTER TABLE and then DROP CONSTRAINT), whether hand-written or generated using Management Studio. I am asking how to do it using only the Management Studio user interface. Because I remember I did it in the past. Only, I've forgotten how to do it because it has been a few months now.
I am using SQL Server Management Studio v17.9.1.
Alright, with some more poking around, I found out what I had done earlier. This is the way.
Right-click on the primary key column when it is open in the designer and select the menu command Indexes/Keys.
Set Create as Clustered to the value No in the ensuing dialog.
See the pictures below.

How to change the index property in Azure SQL Database

I could change the index property in one of the table from Unique, Non-Clustered, Filtered to Non-Unique, Non-Clustered in SQL Server on local machine. But I could NOT find any property in accessing Azure SQL Database via SQL Server MAnagement Studio.
How do I change in via TSQL?
After upgrading to latest SSMS 17.9.1, still not be able to change this via this tool So the query will drop first and then recreated:
DROP INDEX [IX_ClubApplicationUser_LastModifiedBy] ON [dbo].[ClubApplicationUser]
GO
CREATE NONCLUSTERED INDEX [IX_ClubApplicationUser_LastModifiedBy] ON [dbo].[ClubApplicationUser]
(
[LastModifiedBy] ASC
)
GO
This will change into NONCLUSTERED, NON-UNIQUE as well as NON-FILTERED.
The reason we change as the "Code First" approach in .NET CORE 2 generated automatically this type of index.

Log4net ConnectionString Doesn't work with SQL Azure

I tried everything. With a Local File is working and I had to install a instance of SQL Server in my local machine and is also working but when I change my connection string to the SQL Azure doesn't work. I'm testing the same user and password in the Server Explorer inside of my Visual Studio where my application is and works. I don't know what else to do.
I spent the better part of the day trying to figure it out. The problem is that SQL Azure requires clustered indexes on your tables. The example SQL code provided by log4net (http://logging.apache.org/) and 99% of the tutorials on the internet, are to create the Log table does not have a clustered index, which is a requirement for SQL Azure. Adding any data at all to the table will fail unless it has a clustered index.
Try doing a manual insert statement using SQL Server Management Studio while connected to SQL Azure and it will tell you straight away if this is the problem. If so, run the following SQL to add a clustered index on the table (assuming you used the SQL direct from log4net) and then try again.
CREATE UNIQUE CLUSTERED INDEX PK_Log ON [Log]
([Id])
GO

SQL Server 2005 Index Filter Feature

I was told that there is new a feature in SQL Server 2005 called index filters.
What I want to do is add an Index to a column and have the index ignore null values.
I can't find good information on this feature (maybe my source is wrong). Can anyone provide additional information on this feature?
CREATE INDEX ix_mytable_mycolumn ON mytable(mycolumn) WHERE mycolumn IS NOT NULL
This will work only in SQL Server 2008, though.
From the docs:
WHERE <filter_predicate>
Creates a filtered index by specifying which rows to include in the index. The filtered index must be a nonclustered index on a table. Creates filtered statistics for the data rows in the filtered index.
I think you are speaking about filtered indexes, which were introduced in SQL Server 2008, not 2005.
For information, have a look at this article: http://www.sql-server-performance.com/articles/dba/Filtered_Indexes_in_SQL_Server_2008_p1.aspx
Or just do a google search for "sql server filtered indexes".

Resources