Forum Replies Created

Viewing 15 posts - 16 through 30 (of 42 total)

  • RE: Timeout Expired

    Swarndeep (9/17/2009)


    You need to consider on optimize the query and indexes.

    Make sure the maintenance tasks are running regularly as per schedule, like, rebuilding indexes, de-fragmenting etc.

    If a field with auto...

  • RE: Timeout Expired

    Actually I having 2 cases with timeout expired error, both using application to do insertion and selection:

    Case A:

    When insert a record into a table which 1,000,000 records.

    - Getting timeout...

  • RE: Join/Union

    But in this case, I MUST use the EntryDateTime as one of the where selection right? I CANNOT use ExitDateTime as selection because it might return me 0 record?

    Am I...

  • RE: Hourly Group By

    Jim McLeod (8/28/2009)


    It sounds like you're using SQL Server 2000 - I have the same problem running my query under SQL Server 2000. Try this instead, which should work...

  • RE: Hourly Group By

    Jim McLeod (8/28/2009)


    The only way you should get that error is if the "CONVERT(varchar(13), SalesDT, 121)" part used in the SELECT clause is different from the value used in the...

  • RE: Hourly Group By

    Jim McLeod (8/27/2009)


    What was the error? I'm guessing a conversion error, but the following code block works for me:

    CREATE TABLE #Sales (SalesDT datetime, SalesAmt money)

    INSERT INTO #Sales (SalesDT, SalesAmt)...

  • RE: Hourly Group By

    Jim McLeod (8/27/2009)


    You could try converting the datetime to a varchar(13), and grouping by that, with a result like '2009-08-28 13'.

    SELECT CONVERT(varchar(13), SalesDT, 121) + ':00', Sum(SalesAmt) AS SalesAmount FROM...

  • RE: Dynamic WHERE clause

    drew.allen (8/14/2009)


    I think this code is much simpler.

    ALTER procedure Emp_name_proc

    (

    @emp_id varchar(100)

    )

    as

    begin

    declare @sql varchar(100)

    select @sql = 'SELECT EmpName FROM Test WHERE EmpID IN (' + @emp_id +...

  • RE: Join/Union

    Dave Ballantyne (8/20/2009)


    setlan1983 (8/20/2009)

    Just in case where someone changed the entryt.EntryDateTime accidently, need show the record in exit table also.

    But WHICH exit row for WHICH entry row ?

    Presumably 'Bob' will...

  • RE: Join/Union

    pawan.falor (8/20/2009)


    In that case, you may use full outer join as follows:

    select

    ISNULL(entryt.EmpName,exitt.EmpName) EmpName,

    ISNULL(entryt.EntryDateTime,exitt.EntryDateTime) EntryDateTime,

    exitt.ExitDateTime

    from

    dbo.EntryTable...

  • RE: Join/Union

    Dave Ballantyne (8/20/2009)


    setlan1983 (8/20/2009)

    but if I have a case where entryt.EntryDateTime does not match with exitt.EntryDateTime, and I still need to display the record out, how to do that?

    Then what...

  • RE: Join/Union

    Lynn Pettis (8/19/2009)


    This is just a simple left outer join:

    select

    entryt.EmpName,

    entryt.EntryDateTime,

    exitt.ExitDateTime

    from

    dbo.EntryTable entryt

    ...

  • RE: Dynamic WHERE clause

    Thanks for your help and I manage to solve this case.

    "arun.sas" you are such a genius man !!! 😀

    Remark: But cannot view Estimated Execution Plan, got error "Invalid object...

  • RE: Dynamic WHERE clause

    arun.sas (8/13/2009)


    create procedure Emp_name_proc

    (

    @emp_id int

    )

    as

    begin

    1) output like

    ‘Bob’

    ‘Charles’

    select EmpName from Employee/*with lock options*/

    where EmpID = @emp_id

    union

    select EmpName from Employee/*with lock options*/

    where EmpID = @emp_id+1

    2) output like ‘Bob,Charles’

    declare @concat nvarchar(1000)

    select @concat=...

  • RE: Dynamic WHERE clause

    arun.sas (8/13/2009)


    A1)

    create procedure Emp_name_proc

    (

    @emp_id int

    )

    as

    begin

    select EmpName from Employee/*with lock options*/

    where EmpID = @emp_id

    end

    A2)

    insert into TempEmployee

    exec Emp_name_proc 2

    And it’s not advisable to create the procedure with SP_

    Because it’s also reflects/access...

Viewing 15 posts - 16 through 30 (of 42 total)