« first day (1549 days earlier)      last day (3617 days later) » 

12:13
0
A: import damaged SQL MDF file

Rafael PiccinelliI would say this in the comments, but It doesn't fit. I would like to see others answers. Do you have Management Studio right? Try this on the query window: EXEC sp_resetstatus [YourDatabase] ALTER DATABASE [YourDatabase] SET EMERGENCY DBCC checkdb ([YourDatabase]) ALTER DATABASE [YourDatab...

This guy just defaulted to using REPAIR_ALLOW_DATA_LOSS
@KrisGruttemeyer from historical questions, I believe he's young and learning. Hopefully that's not what his senior DBA advised
Also what is DBCC DATABASE?
@MarkSinkinson Yeah, that's why I was gentle with my wording.
@AaronBertrand undocumented/unsupported DBCC command :)
12:28
@KrisGruttemeyer I know many of those.
13:04
morning
Question. We are moving to 2014 and AGs. Right now we are on 2005 SP3. I'd like to set up log shipping to help me out with migrating the data to the new clustered environment. When I set up the secondary, do I target the cluster? One of the nodes? Both of the nodes?
how to get the same answers over and over?
0
Q: assign a value when for integer when USE select query

ShaviaThis question is relevant to SQL SERVER. I have table with column called gender and 1 or 0 will be saved as integer. I want to know whether there is a method assign a label when I Selecting it using SELECT statement. For example "SELECT gender FROM emp" AND if 1 occur "Male" AND 0 occur "Female" ...

@Lamak I can SQL
Interesting that you chose to use Integer rather than BIT or CHAR(1). — Steve Ford 1 min ago
I also thought that was a little odd
13:20
"interesting"
@KrisGruttemeyer you target the clustered instance. But you're not going to use the wizard, are you?
I'm assuming "the cluster" is a clustered instance of SQL Server, not a WSFC. If you are using AGs do you need a clustered instance of SQL Server?
@AaronBertrand God I hope not. I'm walking through it just to see what it does but I'm going to script it, used the old Script to New Query Window.
@AaronBertrand It's a WSFC, yes. AGs, 2 nodes
Ok, so no clustered instance? Target whichever node you want to be the primary to start.
(Which may mean both nodes if you want some AGs to have a primary on one node, and others on the other.)
We're not doing divide and conquer just yet. For now, it will be one AG with all the DBs in it. One primary, one secondary for failover
Now, maybe im misunderstanding 'clustered instance' It will be one namespace (PROD01) with 2 nodes (PROD01\NODE01 and PROD01\NODE02) Application with hit PROD01. Does that make sense?
Wanna make sure I'm using the right terminology
I don't grok "namespace" - you have a Windows Server Failover Cluster, right? You can just put standalone instances of SQL Server on each individual node; you don't need a SQL Server clustered instance on top of that.
You can, but if you're using shared storage then it kind of defeats the purpose of AGs (fault tolerance without shared storage).
13:32
Yes, that's what we are doing. 2 nodes, each has it's own storage and it's own instance. I think we're on the same page but I'm making this more confusing than it should be.
I had thought about just doing the cluster but the shared storage is still a single point of failure
so we talked about AGs and that's what we are going with
morning all
morning blue
seriously?
0
Q: What is SQL_DB?

bamie9lI am deciphering some T-SQL and have the following line: SELECT ProjectType + Project FROM core.dbo.tblProjectV2 WHERE (SUBSTRING(Project, 1, 2) <= @Filter) AND SQL_DB = 1 I've never seen SQL_DB before, it's not defined in my T-SQL script, and it doesn't appear to be a keyword. Ay ideas wha...

Now when I use log shipping to the primary, those transactions will also be applied to the secondary, correct? It's synchronous commit.
he deleted the Q
13:38
I was wondering why the comment didn't come up
> oh my, that's embarrassing, thanks
It amused me
@Lamak he was too embarrassed to leave it
I was about to closed/delete it
it's not like it would be useful to anyone
Quick question. If I have a RowsetID, how do I determine which row it relates to?
(RowsetId 72057600379912192) resides on a read-only filegroup
@KrisGruttemeyer I'm not sure you can set up the AG before you cut over (I've never seen a primary in recovering / recovery pending / standby)
Well, you can set up the AG, but you won't be able to add a database until you can take a full + log backup there.
Which, and again I haven't tried it, I don't think you can do on an actively log shipped target.
13:42
@AaronBertrand That's a good point. I'm wondering if it would just be easier to just turn off the current PROD server, take the full backup, restore it to the primary and secondary (that way they are in sync), then do the AG goodness.
@KrisGruttemeyer If you can have that downtime, yes, that would probably be simpler.
The log shipping avoids the downtime but doesn't reduce the work
@AaronBertrand We have about 18 hours of downtime. Sat night through Sunday. The reason ti's 18 is so we can roll back if needed
Oh that's a luxurious window. Will you have caviar and Chivas for snacks and beverages? Will you be getting massages throughout the operation?
I know exactly how long it takes to restore the full environment with DBCC checks (1hour 40 mins). One of the happy side effects of testing your backups 3x a week. :)
@AaronBertrand There will be scotch. Lots of scotch. :)
@AaronBertrand The AS400 is being upgraded 2x this year (first to go to V7R1, second to move to new hardware). The company will be down for 2 entire weekends because of that. If I can do the 2014 migration overnight on Saturday and have it up and ready by noon on Sunday, I'll be SUPER thrilled.
@KrisGruttemeyer Well, you don't restore the 2005's backup to the secondary. You restore to the primary, then you have to take a full + log backup on the primary to restore on the secondary.
Somehow the AG DDL knows where the backup came from.
13:50
@AaronBertrand Ah, that's right. Forgot about the whole 'full backup on the primary' first.
You can't just tell the AG - hey, see that database over on that other instance? It's in sync!
This will be far easier once the systems guys get the cluster online and I can start testing
I suppose you missed this important event. There is no substitute for a good backup process. There are a bunch of tools that promise they can recover corrupt databases, but I don't believe a single one of them. If the corruption is in fact recoverable you should be able to do this without purchasing any 3rd party tools. Paul Randal has written several posts on this topic (including at least one that warns you NOT to EVER detach a suspect / damaged database): google.com/…Aaron Bertrand ♦ 12 secs ago
14:11
@MarkSinkinson sorry you posted your question on the site before I had a chance to respond here
@AaronBertrand lol "I detach and reattach." That ought to do it.
Also who transcribes that error message? People who can't copy & paste drive me crazy.
(I can tell because deleteLenght and precess.)
14:26
@AaronBertrand Not a problem. Everyone likes Internet points :-)
> select * from validation_log order by stop_time desc where proc_status <> 'Complete'
^^^ runs fine on my machine query
VtC your choice on the reason: unclear, too broad or shopping list
0
Q: Migrate legacy database on SQL Server

Fernando Romano BatistaI'm working on the technological migration of a legacy system, the legacy, uses SQL Server 2014, very good, but, we need to create a new database with new modeling for the new system. The problem is, there are certain tables (most of them) that we will have to keep updated in both databases simu...

14:48
I had the completely right idea
1
A: Restoring plain-text pg_dump with psql and --disable-triggers

Vogel612@dezso had the completely right idea: All this means that some data has been updated, right? Try to update them back, using a temp table where you copy the original data The only thing left now was to make it happen. So here's what I did. I took a leaf out of his book and manually edited t...

and pand.begindatumtijdvakgeldigheid:
0
Q: Slow query over 10mil rows with group by on indexed column

stUrbI've got a slow query which I want to optimize. SELECT pand.bouwjaar AS construction_date, count(*) FROM pand AS pand WHERE pand.begindatumtijdvakgeldigheid <= 'now'::text::timestamp without time zone AND (pand.einddatumtijdvakgeldigheid IS NULL OR pand.einddatumtijdvakgeldigh...

15:09
@AaronBertrand the only thing I have backed up are episodes of MST3K. That download was huge.
Which should tell you how my priorities go. No photo's no documents. Nothing I care if I would lose. Just MST3K and a few SQL scripts.
15:34
0
Q: DatabaseMail didn't start when an email is queued

elty123I have configured SQL agent jobs to send an email when it failed. So far I have received email reliably. However, I have an weird problem where an email would get queued but not delivered immediately. As an example, a job failed on April 1 at 9 AM. When I query SELECT * FROM dbo.sysmail_mai...

Maybe it was playing an April Fools joke?
I was thinking the same thing
16:12
crickets
grasshoppers
This is fun... What game are we playing?
Identify the bug
Tomorrow we'll fix them
uh, that is nasty
ewww
16:22
Sometimes there are big bugs
mmmm lunch
That one is a Little Barrier Island giant weta. He is related to crickets.
> edit Jeepers, whats with the downvotes, its clear question isn't it ? There is even a sql fiddle.
nope, I don't think it's clear
-2
Q: SQL when one column has duplicate rows, then select row where other column is the min value

NimChimpskyI have this table mt.id, mt.otherId, mt.name, mt.myChar, mt.type 1 10 stack U "question" 2 10 stack D 3 30 stack U "question" And I want only rows with id 2 and 3 returned (without using the id as parameter) ...

That guy sounds familiar
11
A: What database technologies do big search engines use?

NimChimpskyGoogle does not use traditional relational database technology. It developed its own technology, big table and map reduce. The original research papers are here : Big Table and Map/Reduce. Also of interest is the SSTable, sorted string table. Similar tech is now used in hadoop and the NoSQL data...

Lots of deleted comments
16:52
@mmarie well that definitely won't haunt my dreams. Thanks a bundle.
:-)
Why is this tagged with sql-server? — Aaron Bertrand 1 min ago
Same reason they all do. Because it's a Server that they are using some form of SQL on.
@bluefeet do you have a suggestion for this mess.
0
Q: How do I do this Pivot (transpose)

beatrice1711Working in SQL-Server, I have the below table: visit temperature treatment denom num pct A <38°C 1 101 98 97.0 A 38.0-38.4°C 1 103 2 1.9 A 38.5-38.9°C 1 100 1 1.0 ...

@Zane yes, would you like me to answer? :)
17:23
Only if you're interested in answering. I'm certainly not going to.
Took one look at that and closed that tab with the quickness.
@swasheck Apparently Kassay likes 'Mr T' as a nick name and thanks you for it.
I'M NOT KIDDIN' MURDOCK
17:55
8
A: Meaning of 'SET' in error message 'Null value is eliminated by an aggregate or other SET operation'

gbnQuick answer The "other SET* is probably related to older SQL Server versions. I used to see it more back when I worked with SQL Server 6.5 and 7 I'm sure, but it's been some time. Many quirks have been ironed out + SQL Server follows standards more Longer: Nowadays, the message is controlled...

I assume there's no way to not have the warning about nulls eliminated through aggregates but force the string truncation to fail "properly"?
The runs-on-my-machine person with the cursor nesting doll proc fills the sql agent job log with the warnings about nulls being eliminated but on the runs where it didn't fill with that, it bombed out due to string or binary data being truncated
damned if I do, damned if I don't. I wonder if mmarie has any wine left
2
Of course I do. My wine owl keeps me supplied.
The #avengeFellas is cracking me up. Mashup of GoodFellas quotes as applied to The Avengers
18:57
@bluefeet im here! Don't forget me
You would think with a user name of LearnByReading, they'd try reading instead of asking poor questions
-1
Q: How does a variable passed as a parameter in Execute SQL Task SSIS?

LearnByReadingI've read the question found here: How to pass variable as a parameter in Execute SQL Task SSIS? And I was wondering if my assumption is correct: 1) *FOR EVERY ROW, the SQL Query specified in the check box "SQLStatement" in the General tab is executed. And the variables are passed on based on t...

19:30
Just had to use the DAC for the first time in a real production situation. Where's that wine again?
@Kermit lies, all lies
@KrisGruttemeyer At least it wasn't a DACPAC
(which only makes me think of this)
@KrisGruttemeyer kill all the spids
Well, I'm certainly awake now.
@AaronBertrand Pacman is the adhoc query, the yellow dots are ALL the resources on that box.
Does anyone know how we could test the impact of using either a DELETE/INSERT of 300k+ rows on a table versus using a MERGE statement on the size of a transaction log? We are trying to figure out if implementing a MERGE would allow us to use log shipping on a few databases. But the test that someone ran shows minimal difference between the operations.
19:34
@swasheck I was surgical, killed the lead blocker (which had 843 blocked spids behind it).
Gave it 5 minutes, and everything caught up
too close for missiles. switching to guns
@bluefeet MERGE is just syntactic sugar over equivalent DELETE/INSERT operations. I really doubt this will have measurable impact in any way whatsoever.
@swasheck I feel the need.....
@AaronBertrand ok, that was my thought as well we were looking for proof in the pudding :)
In fact I would argue that it would be easier to chunk / logically separate the insert/delete operations than try to break up the merge. Affecting fewer rows per operation has a much larger impact on the t-log than what DML command you use.
19:38
@billinkc Hey man, you ever do any sort of dynamic scaleout for SSIS?
If ultimately the whole slew has to be fail or succeed then it doesn't really matter - all changes will have to be logged, and either committed or rolled back as a whole.
@AaronBertrand ok, I'll try and do some testing on that. Basically we have a billing operation that runs every ~2 and we mass insert/delete from about 15-10 tables which are used for reporting. We want to get these tables into a different environment for BI use but the logs are the real issue. They are huge so we are having issues bringing the data down on a frequent basis
Does "mass insert/delete" mean remove/replace all rows?
Have you looked at my schema switch-a-roo posts?
@AaronBertrand yes
That worked for me when I was moving large amounts of data, even though I didn't need to refresh the whole table, it was faster to just swap out the whole thing than worry about what changed.
19:42
Let's say we have a table with 20million rows in it and every 2 hours we add/remove 300k rows which are the current items to be billed. We delete everything for the current period and then re-insert
@MikeFal Nope, anything in particular you trying to tackle?
@bluefeet say it, dont spray it
@billinkc Just noodling some ideas for when we migrate into AWS for our DW platform. Move SSIS to an app server, how could one make some sort of dynamically scaling app layer for SSIS processing.
@bluefeet you delete and re-insert 20 million rows? Or 300K rows?
@AaronBertrand sorry, we delete and reinsert the 300k rows
19:44
Why not keep the current items to be billed in its own table? You can always have a view that union alls the two for cases where you need to see across both current and archive.
This client does something similar. They have the current month's data sitting in the transaction table along with all the at rest data and until it's "committed" it's subject to massive changes. Which they were doing via deletes which took hours
@AaronBertrand that was one of my suggestions this morning. We are looking at a variety of things
Or at least a partition.
We don't need to be querying the 20 million row table each time we run billing, etc
I'm looking at a variety of alternatives to changing all our code to use a MERGE
I've never done any partitioning so that seems foreign to me. I'm thinking about splitting the table though. The current month billing in a "staging" like table and then everything else archived
does SSMS 2014 use more than one thread when connecting to the DAC? I'm just doing new query, nothing is connected in object explorer. Every time I do that, I get a severity 020 error about the maximum number of DAC connections. I thought when you did it through just a new query, it didnt do that
19:47
My initial suggestion was to partition swapping for this but that got shot down because "that's too risky" Then I proposed old school partitioned view. That almost got implemented but then the risk demon rared its ugly head
I can still get in, just curious about that behavior
@KrisGruttemeyer Intellisense and applies to all versions
@billinkc That explains it! thanks
@AaronBertrand I even mentioned using an AlwaysOn read only that we could report on but that would involve infrastructure changes that we can't do yet
@bluefeet I am fairly confident changing all your code to use MERGE is not going to fix anything.
@KrisGruttemeyer SSMS tries to connect on separate threads, yes. IntelliSense, the database dropdown, etc. These are separate from the query window itself. Just ignore the errors.
19:50
@AaronBertrand ok, I'll pass that along. Back to the drawing board for us
20:07
Now that's a horrific pattern if I ever saw one. They build out SQL Commands as strings in a data flow task and export to a file. They then immediately use that command file to run all the statements.
i feel so dirty matching strings like this "hi ... (.+?)," but it's q&d and this script probably wont see anyone else's monitor but mine
What makes this extra special sauce is the query they generate takes the pattern of `update T set BeginCount = (SELECT count(*) FROM dynamically-generated table name) WHERE T.tablename = dynamically-generated table name
And I've already sent them the query that hits the metadata tables to find the exact row count without actually counting
^^ nsfw, btw
@swasheck Thanks for that :)
20:48
@AaronBertrand quick question for you on this. Since we are trying to implement log shipping with our new process, we want the transaction log backup to be relatively small and easy to ship, which is partly why we were looking at the MERGE. Would you expect that deleting/inserting in batches to result in the transaction log backup to be small?
@bluefeet that depends on how you structure your batches. It definitely won't be LARGER than with merge.
JNK
JNK
@bluefeet I know you didn't ask me but in my experience batching just reduces contention, you're still affecting the same number of records so total log growth will be the same
If this is all one big transaction, then it doesn't really matter - the log will grow to account for the same number of row changes.
JNK
JNK
If you grow the log 2 GB all at once or by 200 MB 10 times in a loop it's the same thing
Where batching pays off is when you can back up the log (or checkpoint in simple recovery) between batches, so that you can reuse the log and prevent it from growing. If you're log shipping though, I don't think this will help.
(Because you'll still need to transfer all of those data changes.)
20:51
Ok, I figured I'd ask. We currently have none of this set-up and are contemplating big changes to our current process not knowing if we will get a huge benefit
JNK
JNK
@bluefeet have you done any LS backups yet to see how big theywill be ?
With compression they come out pretty small
I log ship my main transactional DB to two backup servers
Yeah and you could send LS more frequently to keep individual log backups small, e.g. backup the log after every iteration in your loop.
@JNK nope not yet. Right now we are testing our existing process, getting an idea on log size, then the merge, checking log size to see if we get an improvement
You're still sending the same net changes but not in one massive log backup.
I'll bet you poopsenders.com to the victim of your choice that merge nets you 0 or negligible improvement. It is not a performance tool.
JNK
JNK
We do our log backups every I think 15 mins
and apply every 2 or 4 hours depending on the server
20:55
The exact same logical operations have to happen to the underlying table, and those operations have to be logged. It doesn't matter how they got there - MERGE is just a vehicle, like if I want to eat salsa, I don't care if it's on a tortilla chip, a potato chip, or a saltine.
Our thinking is that we'd impact a smaller # of rows using MERGE instead of the giant delete from table / insert into table
that smaller number of changes means less impact to the log
JNK
JNK
@bluefeet Is truncate an option?
our pipeline to bring the backups down here is small so we need the backups to be teeny tiny
JNK
JNK
If you are looking to delete more than half a table
It's pretty efficient rowcount wise to put it into a new table and add the stuff back in
truncate is low logging b/c it's just page deallocations
20:57
@JNK unfortunately no. We have a bad setup - the table is used for reporting and has historical data in it
@bluefeet Oh I thought you were considering UPDATE and not just wipe everything / re-insert everything.
JNK
JNK
@bluefeet Then you move the archived data to another table, union it in a view, and just do your operations on the smaller current data set
OR you use partitioning
@bluefeet I'm telling you, reporting can hit a view that unions monolithic static data and the current
JNK
JNK
@AaronBertrand He's someone's boyfriend
DJ's I think
@AaronBertrand we will with the MERGE use UPDATE - the existing process only deletes and inserts
20:58
@bluefeet But you can do that without MERGE, too.
You know, because reasons
I agree with the use of the view or a separate table but we are looking for biggest bang of the buck as fast as possible
I don't know why this can't be fast
rename big monolithic table
JNK
JNK
ok night all
create a synonym with the current table name that points at the big table
21:00
@AaronBertrand I know, it was never implemented. We don't have "unique" identifiers many of the tables - don't shoot me
create a second table called whatever _current
insert your 300k rows there
@AaronBertrand nice, I like that. I'm going to be testing something like that tomorrow
now create a view called whatever, that does select from monolithic_renamed union whatever_current
(you'll need to drop the synonym and I missed the step where you delete the "current" data from the monolithic table)
true, the table is called by a zillion procs and reports - I'll have to do some other changes to use a view but I agree that might be best
Trust me, this is faster and more bang for your buck than re-writing all your DML to use MERGE. And testing it etc.
You just need to point your delete/insert operation at the new _current table
If you send me some more specific details I can help formulate a more specific plan (sounds like a good blog post to me)
21:06
alright, I'll write something up later today or tomorrow
Thanks for the help/feedback
@AaronBertrand our latest test
With original scripts in place : TLog backup = 3,670,538 KB
With merge statement in place : TLog backup = 2,719,208 KB
reduction of 1GB in size
that was only for one table switched to a MERGE
Yeah but now you're using MERGE
(I know I sound like I'm being flippant but I have actively removed MERGE from multiple customers' systems.)
I passed out your "don't use MERGE" links
it was read and prominently ignored
I wrote up similar syntax without using MERGE but alas it will stay on my hard-drive unused
<shrug> can't fix stupid
21:14
<<<<< overruled
maybe I'll elaborate eventually
If you're going down the route of two tables, might look at making it into a proper partitioned view
> MontlyAllocationNonTransmitted
monty hall y'all
21:20
@bluefeet storage is cheap
;)
@swasheck it was quasi obfuscated from the original and clearly, my obfuscation is the bestest evar
@swasheck storage isn't the problem - it's our pipeline to transfer stuff down here
@billinkc I'll take a peek
@bluefeet it was a joke. late-thursday flamewar
21:34
ha
21
Q: What's the best way to dispose of a body in the backcountry?

ShemSegerSuppose you needed to dispose of a large carcass for one reason or another while in the backcountry... what would be the best way to dispose of it in the woods so that it wouldn't be discovered? You always hear stories of people burying bears that they've had to shoot, but I can't imagine digging...

 
2 hours later…
23:10
Is this just a copy of Kin's answer? — ypercube 1 min ago
he just added a join to sys.schemas

« first day (1549 days earlier)      last day (3617 days later) »