Category Archives: Microsoft

Querying The Most Recent Records

Here’s another fun solution for you business intelligence people out there. Suppose you wanted to pull data that was updated in the last 15mins based on when a row was last. I’m sure there are many ways to accomplish this but I like to use the DATEADD() function in Microsoft SQL Server 2008. Below is the query using the AdventureWorks2008R2 database enjoy.

 

SELECT I.ProductID, I.LocationID, I.Bin, I.Shelf, I.Quantity, P.ProductNumber, P.Name, I.ModifiedDate

FROM AdventureWorks2008R2.Production.ProductInventory AS I LEFT OUTER JOIN AdventureWorks2008R2.Production.Product AS P ON I.ProductID = P.ProductID

WHERE (I.ModifiedDate >= REPLACE(CONVERT(VARCHAR(19), DATEADD(minute,-30,GETDATE()), 120),‘-’, ‘/’))

 

 

P.S. Before the query in the example will work on the AdventureWorks database you’ll need to update a couple of rows on the ProductInventory table.

April #Meme15 Assignment

Another #Meme 15 topic brought you by MVP Jason Strate (blog | twitter). This month topic “What are ten blogs that you think other SQL Server professionals should be following but might not be?” Coming up with a list of just 10 is harder than I thought narrowing it down to ten is just way to hard but i was able to do. The list I  put together covers everyone from the newbie to SQL to the all-round DBA.

  1.  http://sqlchicken.com/sql-university/ Great for the newbies and awesome reference points I hope this page never goes away.
  2. http://www.brentozar.com/ I loved Brent’s old content from 2008 maybe it’s because I work on SQL. 2000 and 2008 servers and probably will be for another five years. Must read the take-over posting !!!
  3. http://www.sqljoe.com/ Great webinars a must join and there in Spanish as well occasionally.
  4. http://blogs.lessthandot.com/index.php?disp=authdir&author=420 I love Jes’s blog lot’s of ah ha moments and she’s a Jaycee woo!!! Check out her RDMS comparison chart posting.
  5. http://www.bidn.com/blogs/ Shout out to all the BI bloggers. Lots of interesting content always flowing through this network.
  6. http://www.jasonstrate.com/tag/31daysssis/ Jason put together an amazing series a must read if your new to SSIS development.
  7. http://blog.sqlauthority.com/ This lots of SQL information on Pinal’s site is another gold mine of DBA information.
  8. http://denglishbi.wordpress.com/ Shout out to the BI bloggers.
  9. http://cwebbbi.wordpress.com/ Shout out to the BI bloggers cause we how to know party.
  10. http://sqlblog.com/blogs/jamie_thomson/default.aspx I read a lot of Jamie’s one-off posting.

Peace Out