« first day (954 days earlier)      last day (3931 days later) » 
02:00 - 21:0021:00 - 00:00

2:45 AM
Any PBM (policy based management) folks about?
 
I know a little
 
Is it possible to use PBM to audit DDL activities?
The DBAs could write a DDL trigger but if they could wizard something, I think I'd have a better chance of them doing it
The other consulting team has to deal with a dumb database design. Identity property assigned on various tables. But, if they need to create "unknown" entities, they have to do an explicit insert into the negative spectrum on the table.
Dumb, dumb, dumb
But they didn't fight hard enough so this is the bed they must lie in.
So, they are running into a permission hatefest where the DBAs have cracked down on permissions in environments and so any time they want to run their ETL, they have to have the DBAs do it since they deny us ALTER permission
 
So are you trying to use PBM to detect when SET IDENTITY_INSERT is issued?
 
I found your post which should dial back the permissions needed (DBAs thought we had to have owner)
Actually, it'd be any ddl that isn't identity_insert
That something PBM would do?
Digging through the facets but it's slow going
Too late in their approach or I'd say change it out to using SEQUENCE since we're on 2012
 
Well "any ddl" is kind of broad. :-)
And for a lot of things PBM is not exactly next/next/next, for example anything that uses ExecuteSQL() is a royal PITA, and sadly that's most stuff.
So I would say a DDL trigger is more straightforward even though it doesn't have a next/next/next option.
 
3:00 AM
Yeah, looking through the ddl trigger now. Oh well, at some point I'll find a good reason to dig into PBM
 
3:25 AM
I haven't found it all that valuable. Primarily because only a small subset of facets fall into the "preventable" category, and prevent is not really prevent - it's actually allow but then rollback.
So, let's say you have a policy that says index names need to start with ix_. A user creates an index named foo, it takes 12 hours to build, then PBM steps in and says, "hold up!" Rollback. 12+ hours later you're back where you started.
DDL trigger can't solve that problem either, but a DDL trigger is advertised as an after trigger. PBM "on change prevent" is extremely misleading in most cases.
In most other cases that's not even a valid option.
 
 
3 hours later…
6:17 AM
Sanity check:
I have a non unique clustered key on an integer and I have a primary key on another integer identity column.
Should I add the primary key as a second column in the clustered key or not?
Using both columns in the clustered key gives 4 + 4 bytes. Using a non unique key gives 4 byte plus a 4 byte uniquifier and an extra 2 bytes because the uniquifier is variable length.
10 bytes for the non unique clustered key and 8 bytes for the two column unique clustered key plus that the primary key values will be part of every non clustered key seams like a no-brainer but I might have misse
 
6:42 AM
The table has (will soon have) about 800,000,000 rows ever increasing and there are about 1,000,000 unique values in the clustered key column and there are 4 more non clustered keys. So size matters here.
Currently watching The Clustered Index Debate
 
@MikaelEriksson Seems like a no-brainer to me too.
 
6:57 AM
@PaulWhite Half way through the video I see that my calculations is not really accurate. There are 2 more bytes added by the uniquifier for "end of row". So I think it is time for a change here. And long due since I designed it like this from the start, 12 years ago.
 
 
5 hours later…
JNK
12:03 PM
quick question for the room - I was investigating a slow insert/update and found a bunch of check constraints on a table. A number of them are just validating values in single columns. Is there any advantage to this over making a lookup table and using a FK?
nevermind, found an answer from our own @ypercube addressing it
 
12:37 PM
There are two problems here essentially: 1) how to return a column value conditionally and 2) how to calculate running totals, because a running total is what you'll need to check on in #1's condition. Apparently the first one is trivial, as for the second one, it's been asked here plenty of times. In light of all that, I'm voting to close this as a duplicate of a past running total question of my choice: stackoverflow.com/questions/11310877/…Andriy M 5 mins ago
 
@JNK A check constraint can potentially be used at compile time to simplify queries.
 
JNK
@MartinSmith in what way? Most of these are lists of allowed values, i.e. CHECK cola = 'a' or cola = 'b'
 
@Lamak Actually it does look as though there is a cardinality estimation bug there.
1
A: Query runs slow with date expression, but fast with string literal

t-clausen.dkThis could work better: Where FK.DT = cast(getdate() + 1 - datepart(day, getdate()) as date) I encountered a similar issue before and this workaround helped me. The expression in the OP appears to be evaluated as though it was a date in the 18th century! CREATE TABLE FK ( ID INT IDENTITY PRIM...

@JNK If you were to then query for cola = 'c' it could just give a plan with a constant scan.
 
JNK
Oh got you, when I SELECT from the constrained table
I think the issue I'm having though is inserts/updates are VERY expensive on this table
And there are a series of check constraints for junk like that
FK seems like it would make more sense to me, especially since we have identical constraints on other tables
 
@JNK The advantages of the FK approach I think is that often an application needs to show a list of allowable items and if this is stored in another table then it is much easier to retrieve. Also easy to knock up an admin screen to allow additional items to be added, also if stored in another lookup table might be more compact as just storing surrogate key in main table. Regarding efficiency I would have guessed check constraints would be quicker to evaluate though.
@ConcernedOfTunbridgeWells Is it too late to express an interest in tomorrow?
 
12:47 PM
@MartinSmith Absolutely not. Please feel free to make an appearance. Do you know where the Wagamama is in Richmond?
 
@ConcernedOfTunbridgeWells Not really but I've just looked it up on Google Maps. It is on Hill Street ?
 
@MartinSmith Yes. Turn left as you get out of the train station, walk down George Street until you get to Hill street. It's near the intersection.
Are you on LinkedIn? I'll send you an invite.
 
@ConcernedOfTunbridgeWells No I've never signed up there. It is still 7:30?
 
@MartinSmith I wonder if it could have anything to do with determinism of a function.
Except it's DATEADD and DATEDIFF of the OP's solution that are always deterministic, and the answerer's DATEPART isn't categorised in any way with regard to determinism. So, if there is a connection, it is not very obvious
 
@MartinSmith Yes. I'll send you a phone number you can get hold of me on. Can you take this down and then I'll delete it:
Got that?
 
12:56 PM
@ConcernedOfTunbridgeWells Thanks. Got it. W
 
You can delete it now.
 
@ConcernedOfTunbridgeWells Thanks. Looking forward to it!
@AndriyM It isn't too far away from 1753-01-01 which is the minimum datetime so I was wondering if it was somehow related to that.
 
@MartinSmith Same here. Good to put a face to the name.
 
JNK
Is today London drinkies day?
 
JNK
another random Q, anyone seen where producing an actual exec plan in SSMS drastically increases time to run a query?
like we just had one go from 24 seconds to 2 seconds
 
@MikaelEriksson Thanks. That mystery was quickly solved!
 
@MartinSmith Found where I was told about it first...
Mar 15 at 7:13, by Paul White
@MikaelEriksson Enable trace flag 4199 and try DT1 again.
 
@JNK not following. You ran the query once with actual execution plan turned on, and it ran in 24 seconds, then you ran it again, and it took 2 seconds? Was it the first time you ever ran that query (so you would pay for the compilation too)? Was the data not in cache the first time (so account for physical I/O on first run vs. logical I/O on second)?
@MartinSmith this sounds like another surprises and assumptions blog post. This time the joke is on me.
 
@AaronBertrand I though the same when I first read the answer.
 
1:23 PM
@MartinSmith it's obscure and I'd hate people to think that any time they're suffering a parameter sniffing issue, changing the syntax will work because it's probably an optimizer bug.
In most cases changing the syntax will appear to work but only because a new plan was generated for the current parameters.
Isn't PowerShell supposed to simplify things? Compare these two scripts and you tell me which is simpler:
0
Q: Error creating XTP Table in SQL Server 2014 CTP1 with Powershell

MrRobHaving a couple of hours to play I created a SQL Server 2014 box on Azure and followed This SQLServerCentral Post to create a File Group and table with T-SQL. All good. I then decided to take a look at doing it with Powershell and I cannot create the table. I think it is to do with my Index creat...

 
@AaronBertrand Actually, frigging stuff through object models tends to be quite verbose. You're really interacting with an API designed for use with languages like C#.
 
@ConcernedOfTunbridgeWells understood, but people often pitch PowerShell as this amazing thing that simplifies everything. It does not always simplify things. In some cases it makes them extraordinarily and needlessly complex.
 
I thought WASD didn't allow you to specify things like files and file groups
 
@billinkc I don't think it's WASD, but Azure VM (which can have a regular on-premise instance of SQL Server).
 
ahhh, gotcha. I'll crawl back into my hole now
 
1:38 PM
WASD = keys you use to move while playing games.
 
Also, hekaton is a way better name than XTP
 
JNK
@AaronBertrand I ran multiple times with plan and was 24 secs each time
I ran multiple without plan and it was 2 secs each time
 
How complex is the plan? Was it one plan or multiple?
When you save the plan to disk, how large is the .sqlplan file?
Did you collect statistics time? Did you try generating an actual plan in Plan Explorer? (The delay might be SSMS rendering.)
 
@AaronBertrand Powershell is Microsoft's third real attempt at a scripting language for Windows. CMD files suffer from lack of features to use any system APIs and lack of the sort of scripting support from system utilities as was found in Unix. The second attempt was WSH, which allowed you to poke at COM APIs through VBScript of JScript.
Powershell was an attempt to build a scripting language with pipelining capabilities and other scripting niceties. It's certainly better than VBScript.
 
@ConcernedOfTunbridgeWells yes, I understand. What I don't get is why people want to shoehorn the language into every possible scenario, where often it's not the right tool.
 
JNK
1:40 PM
@AaronBertrand Not terribly complex, 3 separate queries (2 inserts then an update). I didn't try to save it. It was only in SSMS, not plan explorer yet
 
@AaronBertrand Hammer, nail. Same old story.
 
@JNK obviously collecting a plan is not free, but that seems excessive, so I suspect there is something else going on other than "it takes 22 seconds to collect a plan."
 
JNK
@AaronBertrand you could script out that response to save yourself time in the future
@AaronBertrand I do too, just wasn't sure if anyone had seen that before
 
There is still a 'databases are evil and scary' meme out in the wild among the sysadmin and development community. Some people will go to considerable lengths to avoid having to code SQL.
3
 
@JNK I haven't, to that extreme.
 
1:43 PM
@JNK the 350 attribute/columns XML query I played with the other day took 10 seconds to show the query plan and 1 to execute.
 
JNK
@MikaelEriksson nice
This was pretty simple which is why I was confused, it was like 25k rows, only 10 columns in any of the queries, etc.
 
i love when they restrict access on the server so when I run sp_who, I only get my details
helpful
 
Can't and shouldn't.
4
(for JNK)
 
JNK
Anyone know if you can have both 2008 and 2012 SSMS installed?
 
@JNK yes, you can.
 
JNK
1:58 PM
@AaronBertrand lovely
 
I'd install 2008 first, apply SP3 and whatever the current cumulative update is, then install 2012 with SP1 and CU5.
 
JNK
I have 2008
oh wait I think I can't do 2012 b/c the redgate tools don't have maintenance and I can't upgrade
agggggggggggggg
block select is not working correctly on this machine and it's making me bonkers
I thought maybe it was a 2008/2012 thing
 
I can probably imagne what you mean, but what is "block select"?
Did you press the Ins key maybe? :-)
 
JNK
when you hold alt and select a square (not line-wrapping) block of code
very handy for say adding an alias to a bunch of columns
 
Oh yeah you are expecting Visual Studio region formatting in SSMS 2008. It was added in 2012.
 
JNK
2:04 PM
Really? It KIND of works in 2008
 
It is much more powerful in 2012. Why do you need to use both? Get your employer to renew the maintenance on the Red Gate tools and just switch to 2012 already.
 
JNK
I may just do that
the person who told me we don't have maintenance may not be reliable so I'm looking into it. I did so enjoy 2012
 
2:27 PM
@PaulWhite quite the work environment, eh?
 
3:00 PM
yep
 
@PaulWhite good to see you again, btw
 
@swasheck Glad to be back. Well, not really, but you know what I mean :)
 
JNK
@PaulWhite were you vacationing?
 
@JNK Yes, on a tropical island.
It was very agreeable.
 
JNK
More tropical than sunny NZ?
You are pretty close to polynesia there right?
 
3:04 PM
@JNK Yes. 3.5 hour flight to Rarotonga (Southern Cook Islands).
 
JNK
@PaulWhite nice!
 
It really was!
 
3:17 PM
Oh that reminds me my Vacation is Coming in a huge hurry.
 
@Zane Going anywhere nice?
 
Boston and New York
 
JNK
so, NO
I'm kidding of course, both are nice
 
@JNK LIAR!
 
JNK
Well I like NYC
Boston is OK if you disregard the people
 
3:29 PM
sorry. just wanted to do the princess bride thing
 
The people are what I loved so much the last ime out.
Alhtough they may have been nicer to me due to the copious amounts of free beer I was giving out.
 
Free beer always lubes me up.
Oh, was that out loud
 
@AaronBertrand For that matter, paid beer will probably lube you up just as well. So long as someone else is paying for it. :)
 
JNK
@AaronBertrand for SSMS 2012 only do I need the full install?
 
@JNK no, just check management tools - basic & complete
 
JNK
3:38 PM
awesome
 
If you just want to download SSMS 2012, you can do so here (you want SQLManagementStudio_x64_enu.exe)
You still have to step through many of the setup steps, as if you were installing a new instance. But on the feature selection page you just pick the management tools.
 
JNK
I'm installing now
 
Does anybody else understand exactly what this guy is trying to do? He's lost me and I need to go get lunch
0
Q: run sql server view on local server

Doug_Ivisonall -- I know this is a long shot....... I have a query that executes a view on another server, that I wish I could "redirect", to access data on the local server... (here's the big catch) without the network bandwidth. WHY: A) There's a single T-SQL query hanging up one of our websites. B) In...

 
Is there a someplace where the rules SQL Server uses to parse malformed dates are documented? For example, if my language's dateformat is dmy and someone writes a query featuring the date '2013/08/13', is there someplace where I can read about the rules that result in it treating 13 as the month? (I do know this is a terrible way to write dates.)
 
3:58 PM
@AaronBertrand not the slightest clue as to what he's talking about.
lol job offer 40K for a ORACLE Datawarehouse developer. Good luck filling that one.
 
JNK
@Zane They can't afford more because of all the oracle license $$$
 
@JNK I know places that can't fill 90-120K Oracle positions.
 
4:16 PM
@AaronBertrand I had a go but after reading and re-reading, it sounds like there is no local SQL Server (yet) but he wants to use (a new) one sometimes to cache this data which is too slow to pull across the network. I don't think he's going to have much success with that if his app doesn't architecturally support it.
 
sigh chameleon questions
Thanks for this! Please see updates including both updated code and new errors. — SidC 43 mins ago
 
Hey @billinkc, when should I show up to SQL Sat KC for the BBQ goodness?
 
4:34 PM
sigh chameleon questions
Thanks for this! Please see updates including both updated code and new errors. — SidC 51 mins ago
 
@MikeFal Still haven't nailed down a definitive agenda but be in the area noonish
 
@billinkc Looks like it won't be an issue. The cheapest flight lands me in KC at 9:20 AM
 
Bueno!
 
Could you please highlight the differences more obviously, instead of posting a wall of code and telling us to spot the differences? You can also leave out chunks of code that remain unchanged. I attempted one edit but it was not successful. Thanks. — Aaron Bertrand 3 mins ago
 
@billinkc Now I need to start working on my preso. :)
Last thing I want to do is pull a Horner
 
4:38 PM
I need to get travel to denver under way. And my presentation too.
@MikeFal You know that's due to review committee the end of this month, yeah?
 
@billinkc For the Summit? I knew that was coming up, wasn't sure of the exact date.
 
And by the end of the month, I mean August 23, 2013
 
But that won't be an issue.
 
I've been working on mine but the fact that PPT and demos are due then was an eye openeer
 
@billinkc I have no demos
Well, maybe some minor ones
 
4:41 PM
@billinkc wait, what? PASS session decks and demo code are due August 23rd?
 
Am I reading it wrong? First time at the rodeo as a full blown speaker
 
No story checks out. I'm not going to make that deadline.
 
@billinkc Looks pretty straightforward. Glad I said something, I would have missed this. Thanks.
 
@AaronBertrand You probably have a bit more leeway as a proven speaker. I am nothing but a proven slacker
"Oh yeah, I'll have all that done by the end of July," I told myself
 
@billinkc You and me both
 
4:52 PM
Thar be dragons
0
Q: Triggers: Tracking ID Updates

astangeloFor a trigger that is tracking UPDATEs to a table, two temp tables may be referenced: deleted and inserted. Is there a way to cross-reference the two w/o using an INNER JOIN on their primary key? I am trying to maintain referential integrity without foreign keys (don't ask), so I'm using trigge...

Usually you join on the key, but what if you changed the key? </facepalm>
 
5:04 PM
OHHHHH snap I'm going to have to do my first ever UN-Pivot! @bluefeet
 
@Aaronbertrand Is it possible for us to set up a chat? I'm just having trouble finishing this and am trying to meet a deadline. — omar K 58 secs ago
Your deadline is not the community's problem.
7
After seeing the droves of people who have jobs in IT they don't deserve, I have less and less sympathy for people "trying to meet a deadline" by scraping together crap they've been spoon-fed from strangers. There's still some sympathy there, but it's dwindling away rapidly.
3
 
@AaronBertrand "My rates are $268 an hour, 4 hour prepaid minimum"
 
5:28 PM
@billinkc Your rate is much higher than mine sir.
 
@Zane That's what having SSIS on your resume will do for you, artificially inflate your consulting rates.
 
@MikeFal SSIS is on my resume....
IS AS RS
 
@jcolebrand as an American I often forget there are other people.
 
@Zane might behoove you to work on that spelling there ... ;-)
 
5:40 PM
don't know what YOUR talking about ;)
 
@Zane That's not spelling, that's grammar
 
@MikeFal Well I thought it was funny.
 
If the population of the world were segmented into 7 1 billion population groups
 
Sweet we got @PaulWhite on the green team.
 
 
5:49 PM
@Jimmy It's interesting to see which countries stay roughly the same size.
 
@Jimmy And they say Australia is a continent!
 
To add to the above: No offense, but your comments to the answers below also show a lack of understanding, time pressure, and a "givemetehcodez" feel. I'll let you in on a little secret: we all have our own jobs to do and deadlines, and as far as I know nobody is getting paid to answer questions here on SO. It's a community of people helping people, and you're honestly not making yourself a good candidate to be helped. — lc. 22 mins ago
 
I wonder why they didn't just delete antarctica from that map
 
JNK
@Jimmy Because some people live there
 
Huge fan of that comment.
 
5:51 PM
@Jimmy Because they value penguins as well as people (or better)? Who knows :)
 
JNK
<--- Has SSMS 2012 installed and is a happy camper again
 
@JNK I don't think they have enough to justify the space held on that map.
 
JNK
@Zane looks like a weighted mercator projection so the poles will be bigger in relation to the equator
 
The only problem is that high latitude areas just get stretched out by the area-equalization
 
@JNK I'm not much of a cartographer so I'll just agree.
@billinkc quick question?
 
6:01 PM
@JNK Had a new hire install SSMS 2008 R2 the other dayas part of her initial set up and I was all "Why would you do that?!"
 
Anyone have an opinion of UnPivot in SSIS?
 
JNK
@MikeFal why WOULD she do that?
 
@MikeFal You mean instead of 2012?
Probably used to working in a place where you have no choice.
Just like this guy.
 
I didn't know for a long time that SSMS was backward-compatible
 
@Zane Yes, instead of 2012
Come on, they really prevent you from using SSMS 2012?
 
6:08 PM
is it possible for you to add that to my code so I can test it? Im not too familiar with declaring and setting variables. — omar K 2 hours ago
 
I might be able to get around it honestly. I found that if I do things through the command line it ends up letting me install things.
@MikeFal All used software has to be pre-approved and installed by the software management team.
 
@Zane Remind me never to work for Wells Fargo
 
In meeting 'til 2 CST. Generally prefer to pivot/unpivot in source whenever possilbe
 
Will do. It's not a bad gig. They just take an absurd amount of precaution around nothing getting in or out of our network.
 
JNK
ugghhhhhh @@error checking
 
6:25 PM
@JNK RAISERROR (15600,-1,-1, 'this error has not yet been raised');
@MikeFal it's not so different here at op ... we're just a few decades ahead of wf but we're still restricted
when everyone asks me what i like and what i dont like
i make sure to stink about this
 
@swasheck I'd be having words with some folks if I couldn't install a couple key tools
 
@MikeFal unfortunately it's a couple of key tools preventing access
 
@swasheck Such as?
 
@MikeFal SVP of infrastructure
 
lol
 
6:29 PM
we finally have admin access ... so that's nice
 
@swasheck Yeah, he and I would be having words. At this point, I need SQL Sentry Plan Explorer, the latest version of SSMS, notepad++, and Powershell Pro
 
@MikeFal i installed plan explorer but i dont know if that makes me out of compliance or not
and i use Geany ... portable
 
@swasheck eff compliance. Process is a guide, not a roadblock
 
@MikeFal not when you're in the financial sector
it's both
 
Even with all the precautions in your industry people still manage to sneak a thumb drive of SECRET INFORMATION back to China fairly regularly
 
6:31 PM
I'm aware of the financial sector. My point is that some things are a good idea, but let's not be silly about it. Denying me industry standard tools because your team hasn't "vetted" them is ridiculous.
 
and i'm not cool enough to press that much change ... one of these days i will be :D
@MikeFal oh i agree wholeheartedly
 
@MikeFal Find me one thing that your security team has vetted and denied because you actually found a trojan or something.
And then it's crickets
 
@billinkc 'tis a power thing
 
Exactly, so let's not cast it in another light
 
@billinkc Heh, MY team is to lazy to do that. Hell, they apparently are so busy playing on their Macs that they need me to export reports to Excel for them because they don't have time to push the button in SSRS.
 
6:34 PM
I ain't bitter though
 
The shareholders / board need to be convinced that you're making a security effort. Hence the theatrics.
 
@Jimmy Yup, security theater
 
@Jimmy it's not just them ... it's also the government agencies
 
@swasheck in that case, s/shareholders/stupid electorate/
 
@Jimmy i'm no government apologist ... but it's not JUST them ... it's also corrupt business owners and financiers
 
6:40 PM
Oh dear ... I guess we can't trust anyone these days. Still, it's got to be terrorists. Or maybe MongoDB.
 
6:53 PM
Oh my goodness this Flat File is pivoted soooooooooo wide.
 
Wow, how not to do CSS: Connect gets a makeover connect.microsoft.com/SQLServer/feedback/details/739013/…
 
@AaronBertrand It looks flat. Also the logo positioning bothers me
 
@Zane i dont care about the aesthetics ... i care about the text overflowing the element
 
And someone didn't test their nice rounded corners
Oh yeah, gross, didn't notice that until I squished up my browser
 
@swasheck I see.
@swasheck I didn't scroll down far enough to notice that.
 
7:02 PM
:)
 
THe -------- bleeds through wierd as well.
 
i dont usually keep browsers open fullscreen so the first comment wraps oddly for me
 
Not when you have a big monitor. :-)
 
Same here I just have mine squished up and say very little comments.
 
JNK
can anyone link me to a best practice or document regarding not putting scalar udfs in check constraints on high volume tables?
shudder
 
JNK
perfect
 
@JNK Someone at work considering doing something that will bum you out?
 
JNK
@Zane already done, I'm just investigating infrastructure and what not
I'm making a (rapidly growing) list of things to address
I have 34 check constraints in the database with udfs in them
3 are on the highest volume transactional table that sees maybe a couple of hundred writes a second
 
Egads, you probably already have a bunch of bad data
Seriously, this can all be avoided, people just need to learn to read
Those posts are four years old, and I'm sure I could find older ones if I googled (I happened to know Tibor and Alex both wrote about this)
Also plenty of bug reports going back over 6 years!
 
JNK
oh jesus one of them is a udf that just calls another udf
i have work for years and years here
apparently the nested functions are because they can't modify the functions attached to constraints without dropping and readding the constraint
I guess it didn't occur to them that this is because it could invalidate current data
 
7:18 PM
<facepalm>
 
JNK
wow you guys are in for a treat hearing me dig into this stuff!
 
@JNK What is a treat is not having to dig into it ourselves.
 
JNK
this makes me more concerned about the current regime though
 
@JNK If only the second udf had a cursor in it
 
JNK
they have plenty of cursors elsewhere
I think most of the sql was written by web developers
I have seen 3 deep nested cursors
 
7:31 PM
If only they'd nest their transactions so deep
 
Ugh I wish I still had the wand example I found of the worst SQL I've ever seen in my life.
 
JNK
I found a proc yesterday that had a 400 line IF-ELSE checking 60 different int variables in different combinations
 
@JNK .....
Nuke it from orbit, it's the only way to be sure.
 
JNK
Well my plan right now is to fix the "easy" stuff like the udfs in check constraints or the check constraints that act like crappier FKs
once I have the major/glaring schema issues resolved I want to start refactoring a lot of this code
the problem is they have like 10 level nested sprocs and they all have cursors and string manipulation but I am confident that if I knew the BUSINESS NEED for that outer sproc I could do it with a couple of queries and no loops
most of the cursors seem to be used to call functions and sprocs that just return data, not to make changes
 
7:49 PM
I sense many, many <facepalm> events in your future.
 
i had a guy come tell me today why SQL Server sucks compared to Sybase because it checks data on alter table add constraint by default
 
@swasheck is this all messed up for you as well or is it just my crappy web browser?
 
JNK
@AaronBertrand I do too
 
What does "messed up" mean? The images overlap the sidebar? That's a combination of Community Server (which sucks) and a monitor too small
@swasheck next he'll complain that it will prevent you from running a query that contains invalid syntax.
@swasheck or that Target sells scissors in packaging that's too thick to accidentally cut you through
 
7:56 PM
@AaronBertrand yeah. this guy's purpose in life is to hate microsoft. so we pushed back because we get sick of it. basically we said, "that's a good thing, right? i'd like to make sure that my dbms enforces referential integrity since that's slightly important to the relational data model." {{ now shut up and go back and play with mongo }}
 
JNK
so the neatest one of these ck constraints is on a varchar(512) column for user inputted text
it parses through each character and makes sure it doesn't contain any special characters
 
check (col not like f*ck and col not like sh*t and col not like c*nt ...)
 
JNK
it does a while loop checking each char in the string individually
 
Yuck. Let them input special characters, just filter them out at presentation time.
(I'd say validate the string before inserting, but you need to protect the data closer to, well, the data.)
 
@JNK fix that easy with a change to nvarchar(max) - special characters - DONE
 
8:02 PM
maybe "special characters" like ASCII<32
 
@Jimmy maybe, but you can still let idiots insert that data without failing the insert, and just strip them out at presentation time.
ASCII < 32 doesn't hurt SQL Server, it just might make a mess of the data when it's displayed, if you're not prepared for it.
 
I think some shops might just add all this in DB because "well, it's just a simple constraint, easier than writing additional validation code and tying it into our existing monster of a codebase"
 
Oh I don't doubt that, I'm not saying people don't choose this path on purpose. Just suggesting how it could be better. :-)
 
JNK
that is one of the checks in that string function
Can you put a patindex into a check constraint?
 
@JNK yes, why not?
 
JNK
8:16 PM
I get confused sometimes with limitations on checks vs limitations in filtered indexes for some reason
 
Filtered indexes are much more limited
Check constraint is more "local" if you will - it only has to look at each row at write time and pass or fail. Filtered index has more logic, and is used for both read and write.
 
8:46 PM
Add WITH (NOLOCK) after table you are going to use on the each dataflow task
AHHHHHHHHH!
 
WITH (WINNING_TURBO)
 
WITH(I_HATE_MY_DATA)
 
This is an entirely self contained process.
 
WITH (I DON'T CARE IF THE RESULTS ARE WRONG, AS LONG AS THEY ARE FAST)
 
WITH (I_HATE_YOUR_DATA_TOO);
 
8:48 PM
The only thing hitting these tables are these processes.
 
@AaronBertrand I was struggling with that because a developer wanted to use NOLOCK to avoid deadlocking instead of, you know, fixing the queries.
 
Fixing is overrated. Duct tape FTW
 
INORITE
I already feel my rage gland pulsating
 
I use the NOLOCK option on bulk insert. That's it.
We also have a policy that we can't use <> under any circumstances.
 
JNK
wow patindex works a lot faster
Their function took 1100 ms to run on 10k rows
My patindex replacement ran in 9ms
 
8:57 PM
@Zane That one's easy. SQL Server supports !=
 
They don't want that either.
 
"not < and not >" then
 
JNK
what a ludicrous policy
 
They don't want the logical equivilant. Well if I want to exlude one type out of 50 what's wrong with that.
should I go where blah = type1 or blah = type 2 or blah = type3 oh wait I can't do that either.
 
I imagine the reasoning was that they want seeks everywhere
 
02:00 - 21:0021:00 - 00:00

« first day (954 days earlier)      last day (3931 days later) »