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.
Related
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.
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);
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
I have created a couple of tables in SQL Azure and forgot to mark the primary keys as identity columns. There is no data in the tables yet, but the check box marked Is Identity is disabled.
How do I make an existing primary key an identity column in SQL Azure?
You create a new table. You can't change the IDENTITY property in a regular SQL Server instance either - well, depending on your settings, SSMS might let you, but it doesn't tell you what it actually does behind the scenes - drops the table and re-creates it. Don't believe me? Script it out or profile it.
I have a database that will be used by multiple clients (local installs), the plan is to then copy the data to Azure to allow global reporting etc.
The database will be using GUIDs for it's primary keys.
What should I use for a clustered index on the tables, or does that not matter when adding data to Azure? Do I even really need a clustered index? Azure will have single copy of the database, with all client data in it if that makes a difference.
thanks all.
Although you are allowed to create (and have data in) a table without clustered index in SQL Server, this is not allowed in Windows Azure SQL Database ( WASD / SQL Azure). While you can have the table without clustered index in WASD as definition, no DML statement will be allowed to execute against such a table, i.e. you will not be able to do INSTERT/UPDATE/DELETE statements against table in WASD without clustered index. So, if by any chance data is going to the cloud, you should have a clustered index. For more info, check the Clustered Index Requirement in the Guildelines and limitations for Windows Azure SQL Database.
Some of the recommendations here are incorrect.
NEWSEQUENTIALID() is not allowed on SQL Azure.
In SQL Azure, a clustered index is absolutely required. You can create a table
without one, but you will not be able to add data to it until after
you add the clustered index.
In Azure, the clustered index is used for their back-end replication. Reference: http://blogs.msdn.com/b/sqlazure/archive/2010/05/12/10011257.aspx
I think that your best bet is to use a column with an Identity element as the clustered index, along with a non-clustered index on your guid column. I ran into this exact same problem and after quite a bit of research, it's the solution I eventually came up with. It's a bit of a pain to put together, especially if you already have data in production on Azure, but it seems to be the one that addresses all of the issues.
I feel like it would be simplest to use a NEWSEQUENTIALID, but that isn't an option on Azure.