Viewing 15 posts - 7,111 through 7,125 (of 7,613 total)
/* Author: ScottPletcher */
SELECT
start_date,
end_date AS end_date,
CAST(
DATEDIFF(YEAR, start_date, end_date) - CASE...
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".
October 29, 2012 at 5:12 pm
What is the problem? Do you have NULLs in the the MainZip when it's not present/used?
SELECT D.*
FROM Doctors D
INNER JOIN ZipCodes Z ON
(D.MainZip IS...
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".
October 29, 2012 at 4:41 pm
Don't rely solely on the missing index recommendations from those tables. SQL typically suggests way too many indexes. You need to have someone review all available information before...
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".
October 24, 2012 at 9:40 am
Try using [ ] instead of ' ' around the user name:
DECLARE @sql nvarchar(max)
SET @sql = ''
'DROP USER ['+name+'] --<<--
'
FROM sys.database_principals
WHERE principal_id >...
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".
October 23, 2012 at 8:35 am
I would have to know the version of SQL to know how to answer this.
For 2008+, you have CDC.
For SQL prior to that, they probably wouldn't like my answer, but...
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".
October 22, 2012 at 2:27 pm
lak.konduri (10/21/2012)
one bookingref have one complaintid,
one complaintid have many bookingreferences,
one complaintid have many categories and one category have many complaintid,
one complaintid have...
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".
October 22, 2012 at 2:22 pm
The seed value -- rather than seed + 1 -- is the identity value that will be assigned to the first row inserted into the table.
So, if you want the...
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".
October 22, 2012 at 2:17 pm
I agree, this is way too big for a quick question.
I'd also be willing to bet that much of what they gave you is objectively not designed very well, if...
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".
October 22, 2012 at 2:04 pm
I'd also suggest changing the:
WHERE recovery_model_desc != 'simple'
to:
WHERE recovery_model_desc != N'simple' AND state_desc = N'ONLINE'
You're just wasting time trying to change the db's recovery model if it isn't ONLINE.
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".
October 22, 2012 at 2:01 pm
Look for books and articles by Itzik Ben-Gan; his stuff on T-SQL is superb.
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".
October 19, 2012 at 5:19 pm
I'm a DBA, so yes I use SSMS to get to all my servers. Indeed, I have groups of servers so that I can run the same command on...
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".
October 19, 2012 at 5:16 pm
The straightforward way is:
SELECT
CASE WHEN column_name = 0 THEN 'FALSE' ELSE 'TRUE' END AS column_name
The "avoid a CASE at all costs" way is:
SELECT
...
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".
October 17, 2012 at 12:46 pm
Grant Fritchey (10/11/2012)
ScottPletcher (10/11/2012)
Grant Fritchey (10/11/2012)
ScottPletcher (10/11/2012)
Grant Fritchey (10/11/2012)
As an aside, the CHAR(2) would be a really poor choice for the first column in a compound key. You'd want to...
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".
October 11, 2012 at 12:40 pm
Grant Fritchey (10/11/2012)
ScottPletcher (10/11/2012)
Grant Fritchey (10/11/2012)
As an aside, the CHAR(2) would be a really poor choice for the first column in a compound key. You'd want to use either the...
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".
October 11, 2012 at 12:25 pm
Grant Fritchey (10/11/2012)
As an aside, the CHAR(2) would be a really poor choice for the first column in a compound key. You'd want to use either the INT or the...
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".
October 11, 2012 at 10:40 am
Viewing 15 posts - 7,111 through 7,125 (of 7,613 total)