Forum Replies Created

Viewing 15 posts - 121 through 135 (of 240 total)

  • RE: nvarchar or varchar. Need suggestion

    you are correct (n)varchar is variable length while (n)char is fixed length

  • RE: Printing Each record of a table without using a cursor or temp tables ??

    Print to where?  A printer?  The output window of QA?

    select * from table prints all the data.

  • RE: Converting Seconds to HH:MM:SS

    Try something like this:

    declare @CONTHIST table (Company varchar(4), Duration varchar(8))

    insert @CONTHIST values ('aaa', '01:00:00')

    insert @CONTHIST values ('aaa', '02:00:01')

    insert @CONTHIST values ('aaa', '00:01:00')

    insert @CONTHIST values ('bbb', '00:01:00')

    --works if total is <...

  • RE: Table Variable with Identity Column

    DBCC CHECKIDENT doesn't work with a table variable.  This works fine:

    SET NOCOUNT ON

    Create TABLE #tbl (RowID INT IDENTITY, descr varchar(10) )

    insert into #tbl

    SELECT 'a'

    UNION

    select 'b'

    UNION

    select 'c'

    UNION

    select 'd'

    UNION

    select 'e'

    SELECT * FROM...

  • RE: Getting the week number of a passed in Date

    Yes, it returns the week of the year.  Try this:

    select datepart( wk, '28 Feb 2006')

  • RE: DateDiff??

    How about this:

    create function fnTime(@Hours int)

    Returns varchar (8000)

    as

    begin

    declare @t varchar(8000)

    SELECT @t =  CAST(@Hours/24 AS VARCHAR(2)) + ' Day(s)' + ' and ' + CAST(@Hours%24 AS VARCHAR(2)) + ' Hour(s)'

    return(@t)

    end

    go

    declare @t1...

  • RE: Can I not use CREATE VIEW in a DTS package or sp?

    PW,

    In trying to test both scenarios, the following doesn't work.  Any idea why?

    declare @tblARData table (site int)

    insert @tblARData values(1)

    insert @tblARData values(2)

    insert @tblARData values(2)

    insert @tblARData values(3)

    declare @tblARDataTemp table (site int)

    insert @tblARDataTemp...

  • RE: Can I not use CREATE VIEW in a DTS package or sp?

    I would code the delete using:

    DELETE ar

    FROM tblARData As ar

    INNER JOIN tblARDataTemp As t

    ON t.Site = ar.Site

    Is WHERE EXISTS(...) more efficient than this?

  • RE: Date Range for Join Query

    Just 2 general comments:

    Best practice dictates that table names should be singular not plural because on row is a booking, not a bookings.

    use INNER JOIN syntax such as:

    FROM tbl_hp_bookings_transactions BT...

  • RE: Converting row into columns

    Try something like this:

    declare @Item table(ItemID int)

    insert @Item values (1234)

    insert @Item values (4567)

    declare @Balance table(ItemID int, Location int, Quantity int)

    insert @Balance values(1234,201,12)

    insert @Balance values(1234,301,10)

    insert @Balance values(1234,501,11)

    insert @Balance values(4567,201,22)

    insert @Balance values(4567,301,14)

    insert...

  • RE: Date Range for Join Query

    Try this:

    LEFT JOIN

    (

    SELECT

    B.homeworkerid,

    SUM(transactionamount) AS TransactionAmount

    FROM

    tbl_hp_bookings_transactions BT WITH (NOLOCK),

    tbl_hp_bookings B WITH (NOLOCK)

    WHERE

    BT.bookingid = B.bookingid

    AND

    datepart(m, BT.TransactionDate) = datepart(m, @StartSerial)

    GROUP BY B.homeworkerid

    ) dtHWDiscount

    ON

    (dtHWDiscount.homeworkerid = AU.userid)

     

    or this:

    declare @serialstart datetime

    select @serialstart = '20 Dec...

  • RE: Can I not use CREATE VIEW in a DTS package or sp?

    I would create the views once outside of the DTS package and just reference them within the DTS package and sprocs. 

  • RE: Current Date minus one???

    Just a note about SQL time slices.  SQL Server uses 3 millisecond increments and rounds up.  The last possible time in a day is 23:59:59.997. 

  • RE: Getting the week number of a passed in Date

    You may want to try using a function for something like this, depending on the usage of the statement.

    create function fnGetWeekNo

    (

      @CheckDate Datetime

    )

    returns integer

    as

    begin

      return (select datepart( wk, @CheckDate))

    end

    go

    select dbo.fnGetWeekNo('01...

  • RE: Create a complex commission equation

    Here is a good example explaining the database normalization process

    http://www.bkent.net/Doc/simple5.htm

Viewing 15 posts - 121 through 135 (of 240 total)