Viewing 15 posts - 2,821 through 2,835 (of 4,087 total)
This should give you what you need:
WITH Combined AS(
SELECT MachineID, InstanceKey, TimeKey, RevisionID, rowversion, Account, SchemaClass
FROM TABLE_A
UNION ALL
SELECT MachineID, InstanceKey, TimeKey, RevisionID, rowversion, Account, SchemaClass
FROM TABLE_B
)
, Ordered AS (
SELECT MachineID,...
February 4, 2016 at 11:24 am
I suspect that this will perform much better than having a second CTE and a join.
WITH Combined AS (
SELECT Timestampcol, <other columns>, 'Table1' AS TableName
FROM Table1
UNION ALL
SELECT Timestampcol, <other columns>,...
February 4, 2016 at 8:30 am
Try the following.
WITH orders AS (
SELECT o.OrdID, o.OrdDt, o.CustID, o.MtchID, p.Price, p.OrdLoc, ROW_NUMBER() OVER(PARTITION BY o.OrdID ORDER BY p.OrdLoc) AS rn, MAX(p.OrdLoc) OVER(PARTITION BY o.OrdID) AS MaxLoc
FROM #Ord o
INNER JOIN...
February 4, 2016 at 8:10 am
You're going to need to be a lot more specific. I suggest you start by reading Forum Etiquette: How to post data/code on a forum to get the best...
February 3, 2016 at 12:57 pm
jez.omahony (2/2/2016)
February 2, 2016 at 11:01 am
Change your criteria to MEETING_TYPE IN ('PADA', 'TSM'), then GROUP BY your parent info, HAVING COUNT(DISTINCT MEETING_TYPE) = 2
Drew
January 25, 2016 at 12:40 pm
There are two basic approaches you can use:
1) Use XMLNAMESPACES
2) Use a wild card for the namespace.
Drew
January 25, 2016 at 12:26 pm
Here is another solution that uses new functionality specifically for paging that was introduced in SQL 2012.
DECLARE @pg_num INT = 1,
@pg_size INT = 100
SELECT [USERLOGIN]
,[USERFIRSTNAME]
,[USERLASTNAME]
,[ACTIVETODATE]
,[ACTIVATED]
,[DEACTIVATED]
,[USERID]
FROM
ORDER BY USERID
OFFSET (@pg_num -...
January 21, 2016 at 3:21 pm
J Livingston SQL (1/21/2016)
https://msdn.microsoft.com/en-us/library/ms189461.aspx
am trying to find the source that demonstrates the efficiency of using "unbounded preceding"...I have it somewhere <grin>
will post back if I...
January 21, 2016 at 3:10 pm
Welsh Corgi (1/14/2016)
I need to create a new table that has an Identity Column so that I can delete the duplicates.
No, you don't. You can use a CTE to...
January 14, 2016 at 2:56 pm
Welsh Corgi (1/14/2016)
Thanks.Does anyone have a script that could be adapted to correct the duplicate issue.
Surely you've been around long enough to know how to set up a CTE with...
January 14, 2016 at 2:45 pm
Welsh Corgi (1/14/2016)
Yes there are 3 duplicates when I do a INNER JOIN but I exclude them in the Insert and I keep getting PK Violations. :unsure:
An INNER JOIN won't...
January 14, 2016 at 1:55 pm
Welsh Corgi (1/14/2016)
I execute the following:
SELECT ID
FROM Postal
WHERE ID = 'B5A 5E8'
And it does not return any records.
And what do you get when you execute the following code
SELECT ZipCode
FROM Postal_Codes_Import
WHERE...
January 14, 2016 at 1:53 pm
Welsh Corgi (1/14/2016)
That would help if I included the error. :blush:Violation of PRIMARY KEY constraint 'PK_Postal'. Cannot insert duplicate key in object 'dbo.Postal'. The duplicate key value is (B5A 5B4).
I'm...
January 14, 2016 at 12:43 pm
sqlfriends (1/14/2016)
Thank you, those are good tips.I checked the data, the distinct ones are not few. So I may have to do some replace to make the time correct.
Thank you!
You...
January 14, 2016 at 12:35 pm
Viewing 15 posts - 2,821 through 2,835 (of 4,087 total)