Forum Replies Created

Viewing 15 posts - 286 through 300 (of 1,347 total)

  • RE: EXEC in SELECT question

    To place the value into a resultset, you need a user-defined function, not a stored procedure.

    Having said that, using a user-defined function, where the function itself performs a query on...

  • RE: use of union statement

    select maintitle

    from (

      select 0 As PrimarySort, '' as ord_num, 'this book at top of the list' AS   maintitle

      union ALL

      select 1, s.ord_num, t.title AS maintitle

      from titles t, sales s

     ...

  • RE: While Loop

    See edit above to add code.

  • RE: While Loop

    There is no WHERE clause on your INSERT inside the loop.

    Each time it executes it is replicating the whole Policy_Product table into Policy_Product_New.

    I would create a 2 column temp table,...

  • RE: need Qry assistance

    What is the data type of SERV_DATE ? Is it a true datetime ? Is it possible for a patient to have 2 visits in the same day, and could...

  • RE: ORDER BY clause issue...

    What I don't get is ... you are LEFT JOINING the derived_table, but not using any of the columns in derived_table in the resultset.

    As you know, if you LEFT JOIN...

  • RE: Selective Inner join

    Are you sure your sample data in @tblContacts is correct ?

    Why do Bob Zimmerman and Carla Franks have the same Contact ID ? If these persons don't have unique Contact...

  • RE: The dreaded != operator

    The RTRIM(err) != '' will definitely not be sargable.

    What is in the [err] column that forces you to RTRim it ? Can it have leading spaces also ? If it...

  • RE: The dreaded != operator

    This is the problem I'm referring to:

    select distinct 1

              from exc as e

              where e.ssn=k.ssn

              and rtrim(err) != ''

              and col_dat in ('2006-07-01','2006-07-02', etc . )),...

  • RE: Calling a VB DLL from a Stored Procedure

    Depends on version of VB. If it's VB6 and an in-process COM DLL, then you can probably use the sp_OA_Create and related stored procedures to instantiate a COM object and...

  • RE: The dreaded != operator

    >>The main query has three columns that are subquerys on big tables that use the != operator.

    So, the query is of the form ...

    SELECT

      (SELECT Column FROM OtherTable WHERE ...) As Column1,

     ...

  • RE: Order of an update - benefits?

    >>And I understand SQL normally works oldest to newest rows.

    Where did you get that understanding ? There is no inherent order in which SQL updates under the hood. It...

  • RE: Problem With Temp Table

    T-SQL is parsed.

    Then it is executed.

    The parsing step doesn't deal with the fact that your 2 SELECT INTO's are in mutually exclusive conditional blocks, so it throws the error at...

  • RE: Query returning counts for value ranges

    This works as long as cosize is an integer type:

    Create Table #test (

      cosize int

    )

    Insert Into #Test

    Select 1 Union All

    Select 4 Union All

    Select 9 Union all

    Select 35 Union All

    Select 95...

  • RE: Please help with SQL query

    Should have tested first - that code still returns job 111.

    Here's a corrected, tested solution:

    SELECT j.job_id

    FROM #Jobs As j

    INNER JOIN #Activities As a

      ON (j.job_id = a.job_id)

    GROUP BY j.job_id

    HAVING COUNT(*)...

Viewing 15 posts - 286 through 300 (of 1,347 total)