Forum Replies Created

Viewing 15 posts - 1,111 through 1,125 (of 1,347 total)

  • RE: Query working in one DB, not in another

    Is the data the same, or just the table structure the same ?

    What is the data type of column VALUE1 ? If you run this query in both databases, what...

  • RE: View in queries

    As sugegsted try a join, or try replacing the IN with an EXISTS:

    select CASE WHEN Invoice_FK IS NOT NULL THEN 'Invoice ' + ' Invoice_ID:' + CONVERT(VARCHAR,INvoice_fk) END

      , Amount...

  • RE: bcp help - Direct Output file to a different Server??

    Try with a UNC and shared folder ?

    C:\>bcp "Northwind.dbo.Region" out "\\Server2\ShareName\zz_region3.txt" -Sserver2 -c -T

     

  • RE: hidden system tables

    select * from sysobjects where type = 'S'

  • RE: Clustered Constraint Index?

    You may also want to look into adding locking hints to the processes which are reading the data. Depending on your requirements, you may be able to use WITH NO_LOCK...

  • RE: Clustered Constraint Index?

    Behind the scenes, Sql Server creates a physical index to implement the constraint.

    You can see this by querying the sysindexes system table by querying "where sysindexes.id = object_id('YourTableName')".

    Queries that have...

  • RE: Table Variable

    You're missing the FROM clause ...

     

  • RE: Nested Subquery

    You need a virtual table that returns the ID's you want to use, then join this to the main table to exclude the dupes in the Sum():

    Select Sum(DeniedCharge)

    From DenialStore As DS

    Inner Join

    (

     ...

  • RE: Last Business Day of Each Month

    Depends on your business. Is Saturday a business day ? What if a public holiday falls on a business day right before a weekend at the end of the month...

  • RE: Case in Where with Null

    Select *

    From mytable

    Where unit_id = @unit_id

    And IsNull(product_id, -1) = IsNull(@product_Id, -1)

    Replace -1 with the correct datatype for the ID and if -1 is a valid ID in your domain, replace the hard-coded...

  • RE: Update Rate perfomance

    1 thing that jumps out is the lack of clustered index - so although a fillfactor of 90 is being specified, it only applies to the relatively small index on...

  • RE: INNER JOIN brings a duplicate record

    Post the DDL, relationships between the tables and sample data.

    You could use SELECT DISTINCT *, which will not run as quickly ... and won't solve the underlying problem of either...

  • RE: Top N across groupings

    What if there's a tie for revenue ?

    If there's a tie, the sub-query will return you top 2 rows, but if you join that based solely on Revenue, you can...

  • RE: Top N across groupings

    You may get an elegant soultion to this via sub-queries, but I'd typically solve this with a temp-table (or table variable) that applies a Sequence number to it. Note, in...

  • RE: Error on TOP clause

    >>it is a dinosaur database

    Sqlsaurus Rex ?

Viewing 15 posts - 1,111 through 1,125 (of 1,347 total)