6

The issue here is that SQL Server validates the objects when it parses the SQL statement and so if the object doesn't exist it fails, however, there is a trick to getting around this. SQL Server parses object names in the IF statement, but does not validate objects in the ELSE portion. Instead of checking if the object exists and then taking action if it ...


3

But it seems like, since the user is creating it, it should be able to set who owns it too. Absolutely not. After creation, the object is owned by the schema owner, and it would be a security hole to allow users to take ownership of DBO's objects. How can I get the creating user (SequenceCreator) to own the sequence that it creates without needing a ...


1

I believe this index is confusing SQL Server. The join conditions include T4.f_time>=M.f_time This type of join predicate is generally hard for SQL Server to reason about (greater or smaller, with columns on both sides). The index makes things worse, because it's first key column is f_time and other columns are only included. So for every row from ...


1

Here's a sample to play with: --1. CREATE TABLE dbo.Dim ( Id INT NOT NULL IDENTITY PRIMARY KEY CLUSTERED, CustomerName VARCHAR(2000) ) --index CREATE UNIQUE NONCLUSTERED INDEX uniqueindex1 ON Dim(CustomerName); with q as ( select top 100000 row_number() over (order by (select null)) rn from sys.messages m, sys.objects o ) insert into dim(CustomerName) ...


Only top voted, non community-wiki answers of a minimum length are eligible