Viewing 15 posts - 6,556 through 6,570 (of 7,613 total)
RedBirdOBX (5/20/2013)
Would you be so kind as to provide an example?SalesmanID (PK)
SalesmanSSN (ype, it's the social)
FirstName
LastName
...etc...
ALTER TABLE dbo.tablename
ADD CONSTRAINT tablename__UQ_SalesmanSSN UNIQUE ( SalesmanSSN )
--of course you can name the constraint...
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 20, 2013 at 2:43 pm
If you have an (extremely) large table(s), compress them [if on Enterprise Edition], particularly if they are (almost) never used, such as log/audit tables, etc..
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, 2013 at 2:49 pm
First, you need an index on ceb.New_IndividualId: I'll assume you have that already.
Second, I'd cluster the #tmpIndividualCreateDates table by i.IndividualID: I'll assume you've done that already.
I guess the OUTPUT clause...
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 16, 2013 at 3:52 pm
dwilliscp (5/14/2013)
On the Jobs front.. We almost never put SQL into the Job, but thanks for reminding me to check there too. Thanks to everyone...
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 14, 2013 at 11:01 am
I also search table sys.sql_modules, which contains the code for all sys.objects members of type P, RF, V, TR, FN, IF, TF, and R.
If you want to check for use...
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 13, 2013 at 5:01 pm
When you delete a large or very large numberr of rows at one time, SQL Server defers the actual deletes. The next time a page with deleted r0w(s) 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".
May 7, 2013 at 11:45 am
If the numeric portion is random anyway, definitely use all numeric characters if possible -- you're quite right: prefixing the random numbers with a fixed string will NOT help 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".
May 6, 2013 at 4:08 pm
jenny 12957 (5/6/2013)
im not sure this is the right forum to put this in, but i am working on redesigning our company database, and i was looking for best practices...
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 6, 2013 at 4:00 pm
Just to clarify: with ROW_NUMBER(), you don't have to ORDER BY all the columns you want to SELECT; just one ORDER BY column is fine if that's all you need....
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 6, 2013 at 3:50 pm
I think this will do it; performance will depend on the indexes available on the table:
select sales.*
from (
select distinct TerritoryID
from [Sales].[SalesOrderHeader]
)...
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, 2013 at 12:32 pm
GilaMonster (4/30/2013)
ScottPletcher (4/30/2013)
When rebuilding a nonclustered index offline, SQL has to fully scan the clustered index.
No it doesn't. That would be an inefficient way of running a rebuild. Both 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".
April 30, 2013 at 1:18 pm
GilaMonster (4/28/2013)
2) Up to you. Depends on your requirements...
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 30, 2013 at 10:16 am
That could find the wrong entry and/or miss the entry if it was an index on a view instead of a table. Therefore, the code below is more robust:
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".
April 30, 2013 at 10:03 am
I'd use a CASE expression so you can guarantee the order of execution; you don't need a CTE for that.
SELECT OBSVALUE
FROM OBS
WHERE 1 = CASE
WHEN...
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 26, 2013 at 4:29 pm
Sorry:
SELECT
[values].value,
SUM(CASE WHEN Q1 = [values].value THEN 1 ELSE 0 END) AS Q1,
SUM(CASE WHEN Q2 = [values].value THEN 1 ELSE 0 END) AS Q2,
SUM(CASE WHEN Q3 = [values].value THEN 1 ELSE...
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 25, 2013 at 12:30 pm
Viewing 15 posts - 6,556 through 6,570 (of 7,613 total)