Viewing 15 posts - 3,811 through 3,825 (of 7,613 total)
The second-highest score should always give you the desired value:
SELECT t.ID, t.Score1, t.Score2, t.Score3, ca1.FinalScore
FROM #tmp t
CROSS APPLY (
SELECT TOP...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 23, 2017 at 12:12 pm
If the tables are not too large, you could even consider using CASCADE only when deliberately making changes, i.e., drop the FK constraints, recreate them as CASCADE, change the name(s),...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 23, 2017 at 11:24 am
Just UNION (not UNION ALL) the two tables:
SELECT *
FROM #temp1
UNION
SELECT *
FROM #temp2
ORDER BY <column_name>
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 23, 2017 at 10:57 am
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 17, 2017 at 10:57 am
You can use your initial DELETE, perhaps looping it as well:
DELETE TOP (50000) FROM WHERE DATE BETWEEN X AND Y;
You'd be better off clustering...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 15, 2017 at 12:28 pm
Try this:
SELECT T.InvoiceNumber, T.EntryCode AS InvoiceEntryCode, T.StoreNumber AS InvoiceStoreNumber, T.RptLevel AS InvoiceRptType,
OA1.*
FROM #tmpTransactions T
OUTER APPLY (
SELECT TOP...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 11, 2017 at 3:17 pm
You should look into using sql_variant data type, it could help you do this. You'd have to use the desired data type, or cast to an explicit type, when loading...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 10, 2017 at 4:06 pm
For now, off the top of my head, I don't see any way to avoid a cursor. so that you can dynamically evaluate each expression using sp_executesql. But other than...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 9, 2017 at 9:00 am
And don't forget about extended properties. Those would all be lost too if you DROP/CREATE. As would of course any original "create_date".
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 5, 2017 at 8:30 am
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 4, 2017 at 7:51 am
Change your table to never store the space in the post code column (you can use a trigger to do this, at least until you change the app; you can...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 3, 2017 at 4:05 pm
If the format is always xxx###, then:
SELECT MAX(RIGHT(column, 3))
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 3, 2017 at 4:00 pm
Here's another alternative. Btw, I corrected two holiday descriptions, for Jan and Feb. It's not "President's Day", it's "[George] Washington's Birthday"; I wish the media would stop repeating the wrong...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 2, 2017 at 1:18 pm
I think something along these lines:
SELECT user,
CASE WHEN confirmed_count = user_count THEN 'Confirmed'
WHEN not_confirmed_count > 0 THEN 'Not Confirmed'
WHEN confirmed_with_caveat_count >...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
May 2, 2017 at 8:31 am
Do a data design first -- that is, a logical design -- before you do a database design (a physical design). Otherwise you almost always end up with a poor...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
April 28, 2017 at 1:50 pm
Viewing 15 posts - 3,811 through 3,825 (of 7,613 total)