Forum Replies Created

Viewing 15 posts - 316 through 330 (of 1,347 total)

  • RE: How to return Scope_Identity

    The 2nd INSERT is happening inside a conditional IF block.

    Are you certain the 2nd INSERT is actually inserting ? Have you added PRINT debugging to verify that everything inside the...

  • RE: Index Question

    >>a table can only have one clustered index and it should be your primary key since the records need to be unique

    False.

    The primary key is not always a good candidate for clustering....

  • RE: How to return Scope_Identity

    >>That's exactly what I did, but it's still taking the identity of the first insert!!!

    Does the table being inserted to actually have an identity column ? Post the DDL.

     

  • RE: How to return Scope_Identity

    Why would you use IDENT_CURRENT() ?

    IDENT_CURRENT

    Returns the last identity value generated for a specified table in any session and any scope.

    So, another session on your...

  • RE: How to return Scope_Identity

    Did you read Books On Line ?

    SCOPE_IDENTITY

    Returns the last IDENTITY value inserted into an IDENTITY column in the same scope. A scope is a module -- a stored...

  • RE: How do I concat the letter ''''A'''' to the start of every string that is found in a column?

    T-SQL string concatenation simply uses the '+' operator.

    SELECT 'A' + YourColumnName

    FROM YourTableName

     

  • RE: Query sort question

    >>Obviously a field not used in the SELECT can't be used in the ORDER BY clause.

    Put your SELECT into a Derived Table and add on 1 extra column

    as a sort...

  • RE: Update statement referencing another database from same server

    FROM MyDB2

    The FROM in an UPDATE (or SELECT) expects a table name. You've given it a database name, not a table name.

    You don't need a linked server. The databases are...

  • RE: Too many rows returned

    Like this:

    where NOT (

          p.vendor_addr_l1 is null

      and p.vendor_addr_l2 is null

      and p.vendor_addr_l3 is null

      and p.vendor_addr_l4 is null

      and p.vendor_addr_l5 is null

      and p.vendor_addr_l6...

  • RE: Too many rows returned

    >>Is that not correct?

    Nope, not correct. You've structured it as a NOT IN which creates an unnecessary sub-query.

    If you've already selected FROM the required table, and simply need to filter...

  • RE: Too many rows returned

    That's why the sub-query on Max() is not the correct solution. It doesn't handle customers who made 2 or more payments on the same date.

    What does this do with no...

  • RE: Too many rows returned

    You have included a.date_payment in the resultset.

    It wasn't there in your original question. Which means you wasted effort on providing you the wrong solution.

    When you put a.date_payment in the resultset,...

  • RE: use Case statement to simplify WHERE clause of Select query

    SELECT *

    FROM SchHtmlControl

    WHERE (@optionSchHtmlControl = 1000 And SchHtmlControlID in (1,2) )

    Or       SchHtmlControlID = @optionSchHtmlControl

  • RE: Too many rows returned

    Or another option that should perform well if column payment.CustID is the 1st column in an index:

    SELECT c.custID, c.CustName

    FROM customer As c

    WHERE (c.CustID like '10%' or c.CustID like '20%')

    AND EXISTS (

      SELECT *

     ...

  • RE: create fixed width file using BCP

    Use native format instead of text

    or

    Update the data before exporting, replacing line breaks 

Viewing 15 posts - 316 through 330 (of 1,347 total)