Questions tagged [azure-sql-database]

Azure SQL Database is a relational database-as-a-service from Microsoft. This tag is for questions about Azure SQL Database, NOT SQL Server hosted in an Azure VM (use azure-vm).

Azure SQL Database currently offers Basic, Standard, and Premium service tiers. The Web and Business tiers will be retired September 2015.

Product Home Page

1024 questions
50
votes
4 answers

Can I add a unique constraint that ignores existing violations?

I have a table which currently has duplicate values in a column. I cannot remove these erroneous duplicates but I would like to prevent additional non-unique values from being added. Can I create a UNIQUE that doesn't check for existing…
Matthew
  • 1,693
  • 2
  • 17
  • 27
34
votes
4 answers

EF Code First uses nvarchar(max) for all strings. Will this hurt query performance?

I have some databases created using Entity Framework Code First; the apps are working and in general I'm pretty happy with what Code First lets me do. I am a programmer first, and a DBA second, by necessity. I am reading about DataAttributes to…
Nate
  • 1,727
  • 4
  • 22
  • 33
28
votes
6 answers

Changing the use of GETDATE() in the entire database

I need to migrate an on-premises SQL Server 2017 database to an Azure SQL database, and I'm facing some challenges since there's quite a bit of limitations to go through. In particular, since an Azure SQL database works only in UTC time (no time…
Lamak
  • 2,576
  • 1
  • 24
  • 30
26
votes
1 answer

How can I alter an existing Primary Key on SQL Azure?

I want to modify an existing primary key on a SQL Azure table. It currently has one column, and I want to add another. Now, on SQL Server 2008 this was a piece of cake, just did it in SSMS, poof. Done. This is how the PK looks like if I script it…
Magnus
  • 363
  • 1
  • 3
  • 6
25
votes
1 answer

Why MERGE doesn't insert more than 277 records into a table which is configured with temporal table and a non-clustered index on history table

I found again an issue with SQL Server and MERGE statement and need some confirmation. I can reproduce my issue constantly on a Azure Database (but not on a on premise SQL Server 2017/2019). Please execute following steps (step by step, not in one…
Daniel C.
  • 353
  • 3
  • 6
24
votes
1 answer

Where do this Constant Scan and Left Outer Join come from in a trivial SELECT query plan?

I have this table: CREATE TABLE [dbo].[Accounts] ( [AccountId] UNIQUEIDENTIFIER UNIQUE NOT NULL DEFAULT NEWID(), -- WHATEVER other columns ); GO CREATE UNIQUE CLUSTERED INDEX [AccountsIndex] ON [dbo].[Accounts]([AccountId] ASC); GO This…
sharptooth
  • 1,331
  • 2
  • 9
  • 21
21
votes
5 answers

Azure SQL Database "Login failed for user" in application, but works fine in SSMS

I wanted to try out the contained database users feature on Azure SQL Database V12, but I'm having a problem authenticating that seems odd to me. I created a database called Classifier. I added my IP to the firewall rules so I could connect to…
Ben Collins
  • 312
  • 1
  • 2
  • 9
17
votes
1 answer

How to change name for administrator login on azure sql server

I have myserver.database.windows.net with administrator login John. I'd like to change it to Peter. It is possible, if so, how ? Alter which works with local sql server, doesn't work here ALTER LOGIN John WITH NAME=Peter
Hoppus Hoppard
  • 273
  • 1
  • 2
  • 5
16
votes
6 answers

Rebuild Very Large Primary Key Index

I have a SQL database that is hosted on Azure. The problem is that the size is getting out of control, I can see up to 99% fragmentation in the Primary Key clustered indexes. I'm able to rebuild all other indexes with online=on option and it won't…
Techy
  • 345
  • 1
  • 3
  • 5
16
votes
2 answers

Why is my index not being used in a SELECT TOP?

Here's the run-down: I'm doing a select query. Every column in the WHERE and ORDER BY clauses are in a single non-clustered index IX_MachineryId_DateRecorded, either as part of the key, or as INCLUDE columns. I'm selecting all the columns, so that…
15
votes
1 answer

Poor performing subquery with date comparisons

When using a subquery to find the total count of all prior records with a matching field, the performance is terrible on a table with as little as 50k records. Without the subquery, the query executes in a few milliseconds. With the subquery, the…
14
votes
1 answer

Is this a bug or I did something wrong when I created the table?

I have a table in a Azure SQL Instance (12.0.2000.8) and I found this weird behaviour when I query it. The column is defined as Integer, but it does not respond to the "WHERE" filters, also casting to varchar return weird results. It only happens…
Desenfoque
  • 243
  • 1
  • 6
14
votes
2 answers

Should I drop dbo from the database role db_owner?

I did a Vulnerability Assessment for my database today. I found VA2108 and it suggests me to ALTER ROLE [db_owner] DROP MEMBER [dbo] But it's the default setting of any SQL instance. Should I go for it? And is there any risk? Thanks
14
votes
4 answers

Why does TSQL return the wrong value for POWER(2.,64.)?

select POWER(2.,64.) returns 18446744073709552000 instead of 18446744073709551616. It seems to have only 16 digits of precision (rounding the 17th). Even making the precision explicit select power(cast(2 as numeric(38,0)),cast(64 as…
Triynko
  • 615
  • 1
  • 6
  • 15
14
votes
1 answer

Can I tell when and who updated my database from v11 to v12 on Azure?

Earlier today I noticed that all my Azure SQL database servers where updated from v11 to v12. I am the only one in my company that should be touching those dials, but not the only person in my company with the access. Since I did not initiate this…
Erik
  • 4,833
  • 4
  • 28
  • 57
1
2 3
68 69