An addittion to Mark Sinkinson's excellent comment:
NOT IN requires you compare a single column from one table with a single column from another table or subquery.
You can, actually, perform NOT IN with more than one column.
E.g. this is a prefectly legal* SQL query:
SELECT E.first_name, E.last_name
FROM employees E
WHERE (E.first_name, E....
On SQL Server 2008 R2, SELECT...INTO queries are not eligible for parallelism (this was introduced in SQL Server 2014). So the increased CPU count in production will not help your overall runtime unfortunately.
You could re-run your test with a pre-created BACKUP_TABLE, and then use INSERT INTO...SELECT to see how parallelism affects the test.
there is a built-in feature for this that requires minimum maintenance and is very fast except it works with timestamps.
if you can work with timestamps instead of the version I highly recommend this over manual work.
I know that it's old thread, but I think it will be beneficial to share Paul Randal's post here.
An index rebuild will always build a new index, even if there’s no
fragmentation. The length of time the rebuild takes is related to the
size of the index, not the amount of fragmentation in it.
You cannot use an alias in your where clause
Without questioning any parts of the query, you could do this:
SELECT IIf(ChequeInvoicePaymentId IS NULL, 'OWN', 'PARTY') AS ChequeType, ChequeNumber, Amount
WHERE (IIf(ChequeInvoicePaymentId IS NULL, 'OWN', 'PARTY') = 'PARTY');
A better approach would be directly filtering on the IS NOT NULL:
Workaround: The accepted answer seems to indicate that the conversion needs to happen locally because the OLEDB driver doesn't support it.
So I think a simple workaround (at least in the case of my query which is selecting a null uniqueidentifier in the base case of a recursive CTE) is to declare a null variable:
declare @nullGuid as uniqueidentifier = ...
You mentioned database and server-level settings are the same, but how sure about that are you? And is it possible something is changing a setting at the session level?
This produces the error for me (of course):
SELECT CAST(40000 AS smallint);
But this does not - it just returns NULL as the value:
SET ARITHABORT OFF;
SET ANSI_WARNINGS OFF;
Using the bulk export feature of SSMS, here is the best and easiest method mentioned
SQL Server import and export wizard:
The SQL Server Import and export wizard provides a graphical user interface onto a SQL Server Integration Services (SSIS) package. Once created the package can be automated, to run on a schedule. It can be further configured and ...
This should do the work. I tested it in my test environment, works for me.
CREATE LOGIN [TestLogin] WITH PASSWORD=N'test', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
CREATE USER [TestLogin] FOR LOGIN [TestLogin]
GRANT CREATE TABLE TO [TestLogin];
Create a Login on the server with public ...
Firstly, if they are installing their application then surely it would require their own database and not access to the other databases on this server?
However, granting their login member of the dbcreator server role allows them to CREATE new databases on the server.
If you need to allow them to create a table in an existing database then I'd suggest that ...
I have used a Domain Account for Snapshot Agent and Log Reader Agent,
If you check this answer:
The process could not connect to Subscriber
you will see that the SQLAgent account must have a login on your ServerB and must be a db_owner on your subscription database there.
It does not need to be a sysadmin on your ServerA.
It has ...
It's kind of a barebone question, but...
@DateToUse is the date you are searching for.
@StringOutput is the cto column.
I'm using the ID field as a tie-breaker in order to protect against duplicate or overlapping ranges in from/to fields.
DECLARE @DateToUse DATE
DECLARE @StringOutput VARCHAR(50)
SET @DateToUse = '3/2/2019'
SET @StringOutput = (...
I know this is tagged as 2008R2. Since that's officially out of support, perhaps an upgrade is in your future. If you end up on a version of SQL Server > 2012, you can use code like this:
CREATE OR ALTER PROCEDURE dbo.dynamic_temp ( @TableName NVARCHAR(128))
SET NOCOUNT ON;
CREATE TABLE #t ( Id INT );
DECLARE @sql NVARCHAR(...