Forum Replies Created

Viewing 15 posts - 1,426 through 1,440 (of 1,489 total)

  • RE: Can I use a subquery or would a function be better?

    I am not sure what you are trying to do, but a brief look suggests that you may be able to get away with a select along the lines of:

    SELECT...

  • RE: Is there a easy way to do this?

    FYI, the second version should be faster as it scans YourTable once instead of five times.

     

  • RE: Is there a easy way to do this?

    If possible, normalize the table.

    If you have to live with it, something LIKE this should work.

    SELECT D.u_id, D.job_id, D.Hours

    FROM (

     SELECT u_id, job_id, m_hours as Hours, 1 as HourOrder FROM YourTable

     UNION...

  • RE: join problem

    An obvious typo on my part which is now corrected:

    SELECT B.BookID AS Publication

     ,B.Title

     ,B.ISBN

     ,B.YearOfPublication

     ,P.PublisherName

     ,B.PlaceOfPublication

     ,B.Verified

     ,B.BookType

     ,P1.Surname + ' ' + P1.Initials

      + ISNULL(', ' + P2.Surname + ' ' + P2.Initials, '')

      +...

  • RE: join problem

    Assuming:

    1. A book has at least one author

    2. dbo.BookAuthor.[Sequence] goes from 1 for first author to 3 for third author

    Try something like:

    SELECT B.BookID AS Publication

     ,B.Title

     ,B.ISBN

     ,B.YearOfPublication

     ,P.PublisherName

     ,B.PlaceOfPublication

     ,B.Verified

     ,B.BookType

     ,P1.Surname + ' ' + P1.Initials

      +...

  • RE: Parameter in Select Qry in Stored Procedure

    It could be a data type precedence problem.

    eg If jrlid is a char it will automatically to promoted to a varchar and any indexes on jrlid will not be used....

  • RE: Update one table from another table joined on minimum differences

    Looking this up on th web the following function may be more accurate over short distances (read the contents of the link):

    CREATE FUNCTION dbo.GreatCircleDistance2

    (

     @Latitude1 float = NULL,

     @Longitude1 float = NULL,

     @Latitude2...

  • RE: Update one table from another table joined on minimum differences

    Just managed to have a quick look at this.

    The problem seems to be in the function where rounding can cause the cosine to be greater than 1 when the co-ordinates...

  • RE: Update one table from another table joined on minimum differences

    Not sure about the insert but could try creating the temp table with default db collation.

    create table #temp

    (

     TreeID int not null

     ,Dist float not null

     ,AddressLine1 varchar(50) collate database_default not null

    )

    I do...

  • RE: Update one table from another table joined on minimum differences

    This looks like geocodes although float would be a better data type.

    With geocodes Pythagoras’ therom  does not work very well away from the equator. (It fails completely at the poles!)

    Spherical...

  • RE: Problem with stored procedure

    It could be any number of issues.

    It may be a data type issue.

    ie If AttributeID and/or DateID are not INTs (ie they could be tinyints or smallints) then they

    will automatically...

  • RE: Problem with stored procedure

    You will have to provide more information.

    Your query will not run as Col1 is ambiguous.

    Why do you left join when the join to #temp will take out any nulls in...

  • RE: Help with a simple Function

    You probably have a null in either LastName or Firstname. ( null + 'Anything' = null)

    There is no need for a function as something like the following should work:

    SELECT LastName

     ,FirstName

     ,CASE WHEN...

  • RE: Need help with a query statement

    There is no need for an outer join here:

    SELECT T.*

    FROM dbo.Ticket T

     JOIN dbo.Audit A ON T.ticket_id = A.ticket_id

     JOIN ( SELECT A1.ticket_id, MAX(A1.last_updated_date) AS last_updated_date

      FROM dbo.Audit A1

      GROUP BY A1.ticket_id) D

     -- filter audit...

  • RE: prevent a delete - cross-database

    >> I want to ask what type of sp can be used

    You do not allow your users delete access to the table and force them to use a...

Viewing 15 posts - 1,426 through 1,440 (of 1,489 total)