Forum Replies Created

Viewing 15 posts - 136 through 150 (of 188 total)

  • RE: Intermediate T-SQL Book Recommendation

    The two I keep on my desk, and are full of sticky notes because they are so good:

    Henderson's Guru book mentioned above

    O'Reilly Transact-SQL Programming

  • RE: Finding Unique Combinations of Data....

    select a.*, b.itemnum, b.itemdesc from #t a, #t b

    where a.person = b.person

    and a.itemnum > b.itemnum

    order by 1,2,4

    person itemnum itemdesc    itemnum itemdesc

    ----------------------------------------------------------------------

    Jim 123099 Folding Chairs   123044 Gas Trimmer

    Jim 123105 Elite Vacuum   123044 Gas Trimmer

    Jim 123105 Elite Vacuum   123099 Folding Chairs

    Jim 194122 Shop-Sweep Indoor/Outdoor Vac 123044 Gas Trimmer

    Jim 194122 Shop-Sweep Indoor/Outdoor Vac 123099 Folding...

  • RE: Formatting a date for oracle to read

    Look up "date formats" in BOL.  You can get all the pre-fab constants in a ref titled, "CAST AND COVERT" in the T_SQL library.

    If you a dumping your extract from...

  • RE: Formatting a date for oracle to read

    Push from SQL Server to your ascii extract with this:

    select convert(varchar(25), getdate(), 113)

    My instance of Oracle reads this as a date without using any to_char or to_date functions.

    Be sure to...

  • RE: Formatting a date for oracle to read

    You can tell Oracle to recognize pretty much any format.  How you do it depends on whether you actually have a date data type or a varchar display of a...

  • RE: dynamic sql

    BTW, don't understand why you would select into with an order by?

  • RE: dynamic sql

    select

    1 c1,

    2 c2,

    3 c3,

    4 c4,

    5 c5,

    6 c6

    into #emp_temp

    declare @sql nvarchar(1000), @col_name varchar(10), @orderby varchar(10)

    set @col_name = 'c1' --this has to be one of the column names

    set @orderby = 'desc'

    set @sql...

  • RE: Deleting Duplicate Rows

    Simple and elegant. 

    I am at a loss to understand why we inherit such tables in the first place?!  Primary Keys, Unique Constraints... these seem to be foreign concepts to some.

  • RE: Return date only from getdate()

    I don't like to waste an unnecessary function call when I use this so often I don't forget anyway:

    SELECT CAST(CONVERT(VARCHAR(15),GETDATE(),101) AS DATETIME)AS "TruncAndCastDateTime"

    GO

    SELECT CAST(CONVERT(VARCHAR(15),GETDATE(),101) AS SMALLDATETIME)AS "TruncAndCastSmallDateTime"

    GO

    By the way, smalldatetime is half...

  • RE: Deleting Duplicate Rows

    I keep this terrific article Chris wrote in my virtual briefcase:

    http://www.sqlservercentral.com/columnists/ccubley/findinganddeletingduplicatedata.asp

  • RE: Capturing The Error Description In A Stored Procedure

    "There is a limitation in the Excel driver that effects the 'DELETE' keyword. If you attempt to use it, you will receive the error message, "Deleting data in a linked...

  • RE: Check if date range is available?

    Let the point be that a trigger may be your answer.  You can play with the logic yourself until it meets yours needs.  Maybe like this?

    SELECT     startdt, enddt, jobnum

    FROM         dbo.jobschedule

    startdt  enddt  jobnum

    04/01/2004 04/02/2004 1

    04/01/2004 04/02/2004 2

    04/01/2004 04/02/2004 3

      

     

    alter...

  • RE: eliminate duplicates

    SELECT     *

    FROM         dbo.TableA

    iID sState dDate

    1 InProgress 02/04/2004

    1 Resolved 02/04/2004

    1 Awaiting Feedback 06/04/2004

    1 InProgress 03/04/2004

    2 InProgress 02/04/2004

    2 Resolved 02/04/2004

    2 Awaiting Feedback 06/04/2004

    2 InProgress 03/04/2004

      

    select

    iID, sState, min(dDate) MinDate

    from tablea b

    group by

    iID, sState

    having

    sState = 'InProgress'

    iID sState MinDate

    1 InProgress 02/04/2004

    2 InProgress 02/04/2004

      

    If that's not what you want, show me the result set you expect based on the table...

  • RE: Check if date range is available?

    SELECT     startdt, enddt, jobnum

    FROM         dbo.jobschedule

    startdt enddt jobnum

    04/01/2004 04/02/2004 1

    04/01/2004 04/02/2004 2

    04/01/2004 04/02/2004 3

      

    CREATE TRIGGER jobscheduletrigger

    ON jobschedule

    for insert

    AS

    declare @icount as integer

    set  @icount =

     (select count (*)

     from inserted i

     inner join jobschedule j

     on j.startdt = i.startdt

     and j.enddt = i.enddt)

    if  @icount...

  • RE: eliminate duplicates

    select * from #temp order by 1

    1 4/5/2004 inprogress

    1 4/6/2004 inprogress

    1 4/4/2004 inprogress

    2 4/4/2004 inprogress

    3 4/5/2004 inprogress

    select

    count(distinct intid) countdistinctid,

    datepart(month, progdate) currmonth

    from

    #temp

    where

    state = 'inprogress'

    group by datepart(month, progdate)

    3 4

Viewing 15 posts - 136 through 150 (of 188 total)