April 15, 2016 at 12:08 pm
Steve Jones - SSC Editor (4/15/2016)
About to head off to SQL Saturday Phoenix. Anyone else going?
Wouldn't mind to go even if it was only for the 20-30C
π
BTW when you come over for the Bits, bring warm clothes, someone forgot to tell the weather that it's spring now.
April 15, 2016 at 12:18 pm
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
USE MyWorkplace;
GO
IF (SELECT Name FROM sys.objects
WHERE Name = ProcName) IS NOT NULL
DROP DATABASE MyWorkPlace;
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NOT NULL
BEGIN
DELETE FROM sys.server_principals
WHERE Name = 'Developer';
DELETE FROM HR.Paperwork
WHERE Name = 'Developer';
DELETE FROM Building.Security
WHERE Name = 'Developer';
DROP ENTITY Developer;
END
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NULL
CREATE ENTITY Developer
(DeveloperName VARCHAR(100),
Intelligence INT,
Curiosity INT,
SQLSkills BIT CONSTRAINT DF_HasSQLSkills DEFAULT 1,
--DBA NOTE to HR: where 1 is True and 0 is False
MadCodingSkillz CONSTRAINT DF_Is733T DEFAULT 1,
GeekCreds INT);
[/code]
April 15, 2016 at 12:24 pm
Lynn Pettis (4/15/2016)
Let's back door the DBA.
Innocent or not, that would quickly get someone fired at my workplace. Escorted out without notice, etc.
April 15, 2016 at 12:24 pm
Steve Jones - SSC Editor (4/15/2016)
About to head off to SQL Saturday Phoenix. Anyone else going?
See ya there.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 15, 2016 at 12:28 pm
Brandie Tarvin (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
USE MyWorkplace;
GO
IF (SELECT Name FROM sys.objects
WHERE Name = ProcName) IS NOT NULL
DROP DATABASE MyWorkPlace;
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NOT NULL
BEGIN
DELETE FROM sys.server_principals
WHERE Name = 'Developer';
DELETE FROM HR.Paperwork
WHERE Name = 'Developer';
DELETE FROM Building.Security
WHERE Name = 'Developer';
DROP ENTITY Developer;
END
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NULL
CREATE ENTITY Developer
(DeveloperName VARCHAR(100),
Intelligence INT,
Curiosity INT,
SQLSkills BIT CONSTRAINT DF_HasSQLSkills DEFAULT 1,
--DBA NOTE to HR: where 1 is True and 0 is False
MadCodingSkillz CONSTRAINT DF_Is733T DEFAULT 1,
GeekCreds INT);
[/code]
Make Intelligence and Curiosity tinyint or add a CHECK to avoid negative values.
April 15, 2016 at 12:41 pm
Brandie Tarvin (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
USE MyWorkplace;
GO
IF (SELECT Name FROM sys.objects
WHERE Name = ProcName) IS NOT NULL
DROP DATABASE MyWorkPlace;
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NOT NULL
BEGIN
DELETE FROM sys.server_principals
WHERE Name = 'Developer';
DELETE FROM HR.Paperwork
WHERE Name = 'Developer';
DELETE FROM Building.Security
WHERE Name = 'Developer';
DROP ENTITY Developer;
END
IF (SELECT Name FROM sys.server_principals
WHERE Name = 'Developer') IS NULL
CREATE ENTITY Developer
(DeveloperName VARCHAR(100),
Intelligence INT,
Curiosity INT,
SQLSkills BIT CONSTRAINT DF_HasSQLSkills DEFAULT 1,
--DBA NOTE to HR: where 1 is True and 0 is False
MadCodingSkillz CONSTRAINT DF_Is733T DEFAULT 1,
GeekCreds INT);
[/code]
Further on Luis's good advice, change
USE MyWorkplace;
GO
to
USE master;
GO
otherwise you'll get the error
Msg 3702, Level 16, State 3, Line 6
Cannot drop database "MyWorkplace" because it is currently in use.
π
April 15, 2016 at 1:06 pm
SQLRNNR (4/15/2016)
Steve Jones - SSC Editor (4/15/2016)
About to head off to SQL Saturday Phoenix. Anyone else going?See ya there.
ditto
April 15, 2016 at 1:06 pm
Eirikur Eiriksson (4/15/2016)
Steve Jones - SSC Editor (4/15/2016)
About to head off to SQL Saturday Phoenix. Anyone else going?Wouldn't mind to go even if it was only for the 20-30C
π
BTW when you come over for the Bits, bring warm clothes, someone forgot to tell the weather that it's spring now.
Not sure what to pack. It's warm in the Valley of the Sun, but supposed to be a blizzard in Denver tomorrow. I return late Sat, so leaving a ski coat in the car.
April 15, 2016 at 1:36 pm
Steve Jones - SSC Editor (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Steve Jones - SSC Editor (4/15/2016)
About to head off to SQL Saturday Phoenix. Anyone else going?Wouldn't mind to go even if it was only for the 20-30C
π
BTW when you come over for the Bits, bring warm clothes, someone forgot to tell the weather that it's spring now.
Not sure what to pack. It's warm in the Valley of the Sun, but supposed to be a blizzard in Denver tomorrow. I return late Sat, so leaving a ski coat in the car.
I'm only down the road from SQL Bits and we've got snow forecast for overnight. Admittedly it's only going to be a light dusting but it's April!
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537
April 15, 2016 at 1:46 pm
Greg Edwards-268690 (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
I can see a much better execution plan being generated already.
I like how the OP in that thread had no execution plan due to limitations, but there were no issues with it. :w00t:
April 15, 2016 at 1:54 pm
Greg Edwards-268690 (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
I can see a much better execution plan being generated already.
At least now we have a "Plan"
π
April 15, 2016 at 1:57 pm
Ed Wagner (4/15/2016)
Greg Edwards-268690 (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
I can see a much better execution plan being generated already.
I like how the OP in that thread had no execution plan due to limitations, but there were no issues with it. :w00t:
Just another PICNIC
π
April 15, 2016 at 2:35 pm
Eirikur Eiriksson (4/15/2016)
Ed Wagner (4/15/2016)
Greg Edwards-268690 (4/15/2016)
Eirikur Eiriksson (4/15/2016)
jeff.mason (4/15/2016)
Eirikur Eiriksson (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!Quick fix in three steps
1. Drop procedure
2. Drop developer
3. Create developer
π
Do 2 and 3 in one step as an IF EXISTS. In this case the IF clause will fail and it will be able to create the developer.
You are absolutely right, thank you for the correction π
π
I can see a much better execution plan being generated already.
I like how the OP in that thread had no execution plan due to limitations, but there were no issues with it. :w00t:
Just another PICNIC
π
hehe I like that better than mine. I have always called that a PEBKAC - Problem exists between keyboard and chair.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 β Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 15, 2016 at 2:51 pm
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!
I'm going to have to steal "Don't have a clue how to optimize this due to some limitations"
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 15, 2016 at 2:57 pm
GilaMonster (4/15/2016)
Phil Parkin (4/15/2016)
Anyone have a crystal ball, several hours to kill and feeling masochistic? Dive in!I'm going to have to steal "Don't have a clue how to optimize this due to some limitations"
I'm going to try that 'limitations' ruse on upper management here. Wish me luck.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 15 posts - 53,581 through 53,595 (of 66,749 total)
You must be logged in to reply to this topic. Login to reply