Viewing 15 posts - 46 through 60 (of 85 total)
Good question, and one that not too many of us consider daily. We ought to make note here that DEFAULT has been deprecated in an unspecified future version of SQL...
November 15, 2012 at 6:37 am
Ah, now I understand. Then DISTINCT will be your best bet, as pointed out by GSquared, and as you've already seen for yourself.
November 12, 2012 at 7:33 am
DDL = Data Definition Language = just what you posted: the CREATE TABLE statements.
Since there is a one-to-many relationship, again, why are you doing a JOIN to derive a count?...
November 12, 2012 at 7:27 am
DDL for the tables would be helpful, along with sample data. Based on what you've provided, there is clearly a one-to-many relationship between the tables, so the question becomes, if...
November 12, 2012 at 7:14 am
Maybe, maybe not. Depends on many factors such as indexing, clustering, number of rows in the tables, etc. Check the execution plan to see what's getting processed when. Might surprise...
November 9, 2012 at 2:19 pm
Did you try adding a file group to the first CREATE?
October 12, 2012 at 11:01 am
dtopicdragovic (10/11/2012)
seems to be working.
How would you do it in the following case:
If MilestoneID = 35 Then
MilestoneDate
Else
getData()
So in our case result should...
October 11, 2012 at 11:59 am
dtopicdragovic (10/11/2012)
I have a table of the following structure:
CREATE TABLE [dbo].[Doc_Milestone](
[DocMilestoneID] [int] IDENTITY(1,1) NOT NULL,
[DocID] [int] NOT NULL,
[MilestoneID] [int] NOT NULL,
[MilestoneDate] [date] NULL)
INSERT INTO [dbo].[Doc_Milestone] ([DocID],[MilestoneID],[MilestoneDate]) VALUES (30,10,'2012-10-10')
GO
INSERT INTO [dbo].[Doc_Milestone]...
October 11, 2012 at 10:06 am
Shadab Shah (10/10/2012)
Roland Alexander STL (10/10/2012)
October 10, 2012 at 9:01 am
Jason's got it right. Look at his first post, that's the code you need.
October 10, 2012 at 8:35 am
Oops - double inserted those rows 🙂
But the idea's the same.
October 10, 2012 at 8:25 am
dataman777 (10/10/2012)
No I need to count each city in each state. Removing distinct just gives the total count of cities. Nice guess.
create table dbo.state_city (us_state char(2), city varchar(20));
insert into dbo.state_city
values
('AK',...
October 10, 2012 at 8:24 am
Looks like you want the number of rows in which (e.g.) Fairbanks appears? Then remove the DISTINCT.
October 10, 2012 at 8:00 am
You must drop the existing constraint and create the new constraint. Also, if the PK is the clustering key as well, you should drop or disable any non-clustered indexes before...
October 10, 2012 at 7:56 am
If the SP uses parameters in the WHERE or JOIN clauses, you might investigate the possibility that parameter sniffing caused a bad plan to be cached. There are many excellent...
October 5, 2012 at 12:36 pm
Viewing 15 posts - 46 through 60 (of 85 total)