Forum Replies Created

Viewing 15 posts - 50,911 through 50,925 (of 59,078 total)

  • RE: User Defined Function - Passing and Processing a Table

    Can't do a whole lot for you if you don't post the "simple structure" of the data you're talking about... please click on, read, and provide the information from the...

  • RE: Find Last Day of Month

    In the meantime, please try to figure out what dateformat you'd like for startdate and enddate... I recommend not using one at all.

  • RE: Find Last Day of Month

    karthikeyan (4/29/2008)


    Jeff,

    Thanks a lot for your help!

    I have purified one more time.

    DECLARE @DateStart DATETIME

    DECLARE @DateEnd DATETIME

    SELECT @DateStart = '07/Apr/2008', @DateEnd = '29/Dec/2008'

    SELECT Month = convert(varchar,DatePart(MM,DATEADD(mm,N-1,@DateStart))),

    ...

  • RE: complete records with data from similar records

    If the data is all in one table, there's no need to make it in two separate tables... you can make it appear as if you did that with table...

  • RE: difference

    You both really need to make a trip to Books Online... and, just to be sure, you can do INSERTs, UPDATEs, and DELETEs on Table Variables in a UDF... just...

  • RE: Indexes & tuning

    In this case, I'd say no indexes are necessary on the source table and for speed, the fewer indexes on the target table, the better. If the target table...

  • RE: Ordereing an IP address

    This will do it...

    --===== Create a table to demo with

    DECLARE @DemoTable TABLE (IPAddr VARCHAR(15))

    INSERT INTO @DemoTable (IPAddr)

    SELECT '192.168.215.1' UNION ALL

    SELECT '192.168.23.1' UNION ALL

    SELECT '192.168.5.1' UNION ALL

    ...

  • RE: Is there a way to easily calculate the number of years between two dates.

    Heh... skip the "trees"... try this...

    SELECT ABS(YEAR(DATEADD(dd,DATEDIFF(dd,@BirthDate,@ReferenceDate),0)-1)-1900)

  • RE: best way to remove duplicates when no primary key or date present

    So, which columns constitute a dupe? Just the first two or all of them?

  • RE: Date Addition

    GSquared (4/28/2008)


    create table dbo.Numbers (

    Number int identity (0, 1) primary key,

    Junk bit)

    go

    insert into dbo.Numbers (junk)

    select top 10000 0

    from sys.all_objects s1

    cross join sys.all_objects s2

    go

    alter table dbo.Numbers

    drop column junk

    go

    select dateadd(day, number, '1/1/1900')

    from...

  • RE: Boost TSQL query code

    p.s. For future reference, it's almost always going to be a huge performance drain to try to join to aggregated columns like you have. Preaggregation using a temp...

  • RE: Boost TSQL query code

    I believe every one has hit all the hot spots... Carl's last post should be a big help, as well. The problem is that the derived table in the...

  • RE: Issues related to the speed of the execution of sql statement in mssql server 2005

    That covers just about all of it... can't think of anything else to check unless the WHERE clauses have a formula in one and not the other.

  • RE: Fetch Row by Row with out using cursor

    Grant is correct. Tell us what needs to be done... not how to do it. There's usually no need for any form of RBAR. Post some data...

  • RE: Find Last Day of Month

    karthikeyan (4/29/2008)


    Jeff,

    I have refined the above code as

    DECLARE @DateStart DATETIME

    DECLARE @DateEnd DATETIME

    SELECT @DateStart = '04/Apr/2007', @DateEnd = '29/Apr/2008'

    SELECT convert(Datetime,'01'+'/'+convert(varchar,DatePart(MM,DATEADD(mm,N-1,@DateStart)))+'/'+convert(varchar,DatePart(YY,DATEADD(mm,N-1,@DateStart))),103),

    DateAdd(DD,-1,convert(Datetime,'01'+'/'+convert(varchar,DatePart(MM,DATEADD(mm,N,@DateStart)))+'/'+convert(varchar,DatePart(YY,DATEADD(mm,N,@DateStart))),103))

    FROM dbo.Tally

    where DateAdd(DD,-1,convert(Datetime,'01'+'/'+convert(varchar,DatePart(MM,DATEADD(mm,N,@DateStart)))+'/'+convert(varchar,DatePart(YY,DATEADD(mm,N,@DateStart))),103)) <= @DateEnd

    I got the below output:

    Apr...

Viewing 15 posts - 50,911 through 50,925 (of 59,078 total)