Forum Replies Created

Viewing 15 posts - 46 through 60 (of 85 total)

  • RE: Defaults

    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...

  • RE: JOIN for beginners

    Ah, now I understand. Then DISTINCT will be your best bet, as pointed out by GSquared, and as you've already seen for yourself.

  • RE: JOIN for beginners

    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?...

  • RE: JOIN for beginners

    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...

  • RE: Subquery

    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...

  • RE: Error when creating a table

    Did you try adding a file group to the first CREATE?

  • RE: SELECT statement, can't decide on the approach

    dtopicdragovic (10/11/2012)


    Thanks for help

    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...

  • RE: SELECT statement, can't decide on the approach

    dtopicdragovic (10/11/2012)


    Hi!

    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]...

  • RE: Alter constraint on Primary Key

    Shadab Shah (10/10/2012)


    Roland Alexander STL (10/10/2012)


    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...

  • RE: Counting distinct row numbers

    Jason's got it right. Look at his first post, that's the code you need.

  • RE: Counting distinct row numbers

    Oops - double inserted those rows 🙂

    But the idea's the same.

  • RE: Counting distinct row numbers

    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',...

  • RE: Counting distinct row numbers

    Looks like you want the number of rows in which (e.g.) Fairbanks appears? Then remove the DISTINCT.

  • RE: Alter constraint on Primary Key

    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...

  • RE: High CPU usage (Because of bad execution plan)

    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...

Viewing 15 posts - 46 through 60 (of 85 total)