Forum Replies Created

Viewing 15 posts - 391 through 405 (of 416 total)

  • RE: SQL Date Parameters not working

    Whereas:

    >= '20140101' AND < '20150101'

    continues to work accurately for all those data types.

    +1

  • RE: SQL Date Parameters not working

    BWFC (12/4/2014)


    I'm really not following you here.

    declare @startdate datetime = '2014-12-04'

    declare @enddate datetime = '2014-12-05'

    create table #EventHeader(

    HistoryID int primary key not null

    , DateTimeHappened datetime not null

    )

    insert into #EventHeader

    select 100001, '2014-12-01' union all

    select 100002,...

  • RE: SQL Date Parameters not working

    BWFC (12/4/2014)


    ScottPletcher (12/3/2014)


    BWFC (11/27/2014)


    You're welcome.

    One other thing, be careful using BETWEEN for date range queries. You're usually better using

    where

    [Date] >= @startdate

    and

    [Date] <= @enddate

    Have a look at...

  • RE: What will be the output message?

    Yeah, I've been bitten by text columns when I was unfamiliar with the schema.

  • RE: T-SQL Development Standards

    Jeff Moden (10/25/2008)


    As soon as something needs to "go in in a hurry", all notions of standards and well intended code reviews will go by the wayside.

    +1

  • RE: Alter the schema from one view causes the need to alter the other

    GilaMonster (11/28/2014)


    Or stop using SELECT *

    + 1000

  • RE: Calculate age - Most easiest way

    dave.ott 20779 (12/2/2014)


    I've always liked this to get the age in years

    select cast(datediff(d,@dob,getdate())/365.25 as int)

    This has problems on birthdays. As listed, the code returns 0 when dob = '12/2/2013'...

  • RE: SQL Date Parameters not working

    Unfortunately, this is legal ANSI/ISO Standard SQL so it has to work. But you ought to get a warning!

    Rather than defaulting to "1," maybe they could make it work like...

  • RE: IF EXISTS vs @@ROWCOUNT

    Hugo Kornelis (11/26/2014)


    Sorry for the harsh words, but this is absolute rubbish.

    The code in option 2 will always do two lookups. One for the EXISTS, and then another one for...

  • RE: IF EXISTS vs @@ROWCOUNT

    peter.row (11/26/2014)


    I answered neither because neither option answers the question posed.

    You say you have an identity column, you add 4 rows and want to add a 5th.

    Since this is a...

  • RE: Odd Man Out

    Koen Verbeeck (11/20/2014)


    I'd argue ROWCOUNT_BIG is an odd one as well, as it is not calculated over the current result set, but over the results of a previous query.

    +1

    Also, ROWCOUNT_BIG...

  • RE: Memory

    Yep, incomplete information in the question. I'm surprised it got past the gatekeeper(s).

  • RE: Problem with creating a Index on a temp table

    Since it's a one column key, you can put the constraint on the column definition:

    CREATE TABLE [dbo].[#ShipTo]

    ([Ship_to_Num] [int] not null PRIMARY KEY CLUSTERED,

    [Country_key] [nvarchar](3) NULL)

  • RE: Primary Key datatype Bigint vs uniqueidentifier:

    MMartin1 (11/5/2014)


    ... surrogate keys are a data warehouse concept and not in the operational data system ...

    Actually, this is not correct. E.F. Codd introduced the concept of surrogate keys...

Viewing 15 posts - 391 through 405 (of 416 total)