Viewing 15 posts - 1,261 through 1,275 (of 5,588 total)
Hi GSquared,
This is meant to be run one time to create the procs, that are then used to get the data. Of course, they need some modifications to add a...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 31, 2011 at 3:38 pm
How about some dynamic sql to dynamically create the stored procedure for doing this properly instead?
SELECT 'CREATE PROCEDURE dbo.[spGet_' + ss.NAME + '_' + st.NAME + '] AS SELECT '...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 31, 2011 at 1:44 pm
I took your code, formatted it with SQL Prompt Pro, and then eliminated three of your cursors. Look it over, see if it works correctly, and then see if you...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 31, 2011 at 12:02 pm
peterzeke (5/31/2011)
WayneS (5/27/2011)
peterzeke (5/27/2011)
WayneS (5/27/2011)
Pete,
2 questions:
1. Based upon the new row being added to the sample data, what are your expected results?
2. Does Drew's approach solve your issue?
Starting with #2...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 31, 2011 at 9:16 am
Good - you've gotten the business logic down. Now, if you'll post the table definitions, sample data, and the c.u.r.s.o.r. code, we can help you do it fast.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 31, 2011 at 9:07 am
Good question, with excellent false answers.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 30, 2011 at 9:34 am
GilaMonster (5/30/2011)
Please post table definitions, sample data and expected results as per http://www.sqlservercentral.com/articles/Best+Practices/61537/
This appears to be easily solved with:
SELECT [Item Code], Qty = COUNT(*)
FROM [a Certain Table]
GROUP...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 30, 2011 at 5:48 am
Grant Fritchey (5/29/2011)
WayneS (5/28/2011)
Grant Fritchey (5/28/2011)
WayneS (5/28/2011)
Jim Murphy (5/27/2011)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 30, 2011 at 5:37 am
BTW, this (an administrative task) is actually one of the few good uses of a cursor. If you find yourself going to a cursor for other data retrieval operations, STOP....
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 29, 2011 at 5:28 am
hxkresl (5/28/2011)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 29, 2011 at 5:25 am
Jeff Moden (5/28/2011)
Roy Ernest (5/27/2011)
GSquared (5/27/2011)
SQLkiwi (5/26/2011)
Steve Jones - SSC Editor (5/26/2011)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 29, 2011 at 5:20 am
Here's the profiler run on my more modern computer between my code and Jeff's code:
The things that I'm curious about:
1. Why aren't the # of reads between runs on your...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 28, 2011 at 3:17 pm
GilaMonster (5/28/2011)
A copy_only backup isn't going to speed anything up. It's a backup that simply doesn't change the differential base, nothing more.http://sqlinthewild.co.za/index.php/2011/03/08/full-backups-the-log-chain-and-the-copy_only-option/
Perhaps an easier to understand way of saying this...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 28, 2011 at 12:20 pm
Okay, I converted my earlier code to run with the sample table that Jeff created (removed one cte to create the RN column; renamed RN to SomeID throughout):
;
WITH cte AS
(
--...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 28, 2011 at 12:07 pm
Jeff Moden (5/27/2011)
WayneS (5/27/2011)
Sean Lange (5/27/2011)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 28, 2011 at 10:55 am
Viewing 15 posts - 1,261 through 1,275 (of 5,588 total)