New answers tagged

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 ...


0

Synchronous or asynchronous AG's? How are your AGs "layed out"? https://www.sqlskills.com/help/waits/logpool_consumer/ This wait type is when a thread is waiting for an operation to do with the log pool. This is an in-memory cache of recently flushed log blocks, to help avoid log readers having to do physical reads of the log file (e.g. for ...


0

I'm pretty sure there is no way to create or manipulate table-type values in SELECT statements which is what you seem to want. For the single row example you could create a wrapper function which takes the values you want in the table variable as individual arguments, creates a table variable containing them, then calls the existing function and forwards on ...


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 ...


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) ...


0

Thank you to all who answered, the solution turned out to be changing registry entries. As I mentioned, this development server was a VM Clone of the production server. Although it ran without issue for 18 months (or so), on 5 June SQL Agent ceased functioning properly. @randi-vertongen suggested I execute @@SERVERNAME, the result was the name of the ...


0

Any ideas of how to dynamically create and fill multiple session temp tables at different locations in the same run? Dynamic queries and stored procedure invocations are both "nested scopes". Existing temp are visible in nested scopes, but temp tables created in nested scopes are automatically dropped at the end of the nested scope. So the ...


Top 50 recent answers are included