Viewing 15 posts - 2,251 through 2,265 (of 7,191 total)
You haven't provided much detail, but would something like this work?SET XACT_ABORT ON -- either use this setting or handle errors for the INSERT in your code
BEGIN TRAN
INSERT INTO DB2.dbo.TargetTable...
October 14, 2016 at 2:13 am
This should get you started. You'll need to tweak it, even if only to get the 0 for the first date.WITH NumberedDates AS (
SELECT
Customer
,PurchaseDate
,ROW_NUMBER() OVER (PARTITION BY Customer ORDER...
October 13, 2016 at 9:55 am
Are the two tables in the same database? If so, have you considered putting the INSERT and UPDATE statements in a transaction?
John
October 13, 2016 at 9:48 am
Perhaps the statistics on your tables are out of date. Try updating them with FULLSCAN.
John
October 13, 2016 at 2:23 am
October 12, 2016 at 7:22 am
I can't see any value in backing up a database that is a copy of another database that's already being backed up.
Also, are your backup files really on the same...
October 12, 2016 at 3:03 am
That's all a bit vague, although if I had to guess I'd say that you're missing some parentheses around your AND and OR conditions. ANDs are evaluated before ORs...
October 11, 2016 at 9:34 am
A UNC path starts with a double backslash.
John
October 10, 2016 at 10:17 am
H:\ isn't a network share - it's a mapped drive. Drives that you have mapped are visible only to you, not to the SQL Server service account. Try...
October 10, 2016 at 9:50 am
What do you get if you run this?EXEC xp_cmdshell 'dir C:\Users\moody\Desktop\api.json'John
October 10, 2016 at 9:21 am
You've lost me, I'm afraid. Please will you post the whole statement and the whole error message?
Thanks
John
October 10, 2016 at 8:42 am
Here's one way of doing it:WITH SecurityExamples (Line, Value) AS (
SELECT 1, 'G H2' UNION ALL
SELECT 2, 'G-M3' UNION ALL
SELECT 3, 'G U4' UNION ALL
SELECT 4, 'G-X2' UNION ALL
SELECT 5,...
October 10, 2016 at 4:57 am
Something like this:
IF EXISTS (
SELECT ID
FROM Inserted i
JOIN Deleted d ON D.ID = I.ID AND D.Department <> I.Department
)
BEGIN
<Your INSERT statement here>
EXEC sp_send_dbmail <mail parameters here>
END
John
October 6, 2016 at 7:37 am
Use the Inserted virtual table to compare the value of Department before and after, and only insert those rows where it differs.
John
October 6, 2016 at 7:22 am
BWFC (10/6/2016)
And finally, is anybody going to be at SQL Relay in Leeds tomorrow?
Yes. See you there!
John
October 6, 2016 at 2:22 am
Viewing 15 posts - 2,251 through 2,265 (of 7,191 total)