Viewing 15 posts - 46 through 60 (of 90 total)
Also consider Table Value Parameters or some other kind of list shredding method.
April 17, 2013 at 5:42 pm
Since the number of days in a week is not likely to change, you can then write a "SELECT AVG(x) GROUP BY y" type of cross-tab query.
Further reading: http://www.sqlservercentral.com/articles/T-SQL/63681/[/url]
Example:
SELECTc.week_of_year...
April 16, 2013 at 4:01 pm
First of all, I recommend creating a permanent calendar table. A very simplified example would be something like this:
---------------------------------------------------------------------
---------------------- Create a calendar table ----------------------
---------------------------------------------------------------------
create table calendar (
date_key date primary...
April 16, 2013 at 3:51 pm
You'll probably need a query that GROUP BY the name column. Combine this with a HAVING search condition that checks for MIN(), MAX() and COUNT(DISTINCT ) should get you...
April 15, 2013 at 5:33 pm
No worries, it happens to all of us at some point 🙂
Also, here are a couple of newbie-unfriendly defaults that you may wish to change:
1. Please consider moving the database...
April 11, 2013 at 9:21 pm
Looks like a typo in your file path
CREATE DATABASE ApressFinancial ON PRIMARY (
Name = N' ApressFinancial ',
FILENAME = N' C:\Program Files\Microsft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL.mdf' ,
SIZE = 4096KB ,
MAXSIZE...
April 11, 2013 at 8:48 pm
Can you please provide the CREATE TABLE statement of the h table you are referring to, as well as some sample data?
Edit: A small test to get you started...
April 11, 2013 at 5:47 pm
Lynn Pettis (4/11/2013)
My question is what is the value of S.EndDate when this query was run.
I'm taking it to mean that we need to "anchor" the #student table to return...
April 11, 2013 at 5:37 pm
Thanks for describing the tables schema - can we please also have some sample data in these tables, like this:
http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]
April 11, 2013 at 4:34 pm
Without knowing the exact DDL, I'm guessing that adding yet another index won't help the update speed. I think the update is slow because you are getting page splits...
April 11, 2013 at 3:52 pm
The above suggestion works great for a hierarchy one level deep.
You may also want to see if you need a recursive query, something like this:
http://msdn.microsoft.com/en-nz/library/ms186243%28v=sql.100%29.aspx
April 11, 2013 at 3:19 pm
Like the previous poster said, the best solution is to "armour plate" the divisions with nullif.
As for the SET ARITHABORT and SET ANSI_WARNINGS, it sounds like you had them outside...
April 11, 2013 at 3:13 pm
1. Joining integer columns (provided that they are correctly indexed) is faster than joining other data types because it is relatively straightforward (see below)
2. It depends. Varchar...
April 11, 2013 at 2:56 pm
One thing to consider also: Will there be "holes" in your data, e.g. a company does not have a stock quote for a day due to a trading halt or...
April 11, 2013 at 2:39 pm
A couple of self-joins should do, something like that:
selectpt.symbol,
pt.quote_price - p3.quote_price as change_3_day,
pt.quote_price - p6.quote_price as change_6_day
from pricedata pt
left join pricedata p3 on p3.symbol = pt.symbol and p3.quote_date...
April 10, 2013 at 11:06 pm
Viewing 15 posts - 46 through 60 (of 90 total)