Forum Replies Created

Viewing 15 posts - 2,491 through 2,505 (of 3,544 total)

  • RE: rewrite code to eliminate isnull

    As Douglas has mentioned a lot depends on the whole query and data structure and whether the date column is indexed.

    If the date column is indexed isnull will use index...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Urgent~How to use OpenDataSource to query from another server???

    I have posted in your other thread re OPENROWSET. Are these two related?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to use OpenRowSet?

    Join the two queries together, you can reference the result of the OPENROWSET as a table

    SELECT J.Job_ID, J.J_Open_Date, J.J_Priority, J.J_Vendor_ID, P.VendName

    FROM Job_Tracking_Table J

    INNER JOIN OPENROWSET('SQLOLEDB','AMKSQL2';'abc';'cde', 'SELECT VendorID, VendName...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Finding datetime range intersections and durations

    DECLARE @hours TABLE (Tagname varchar(256), H int)

    insert into @hours

    select c.Tagname,v.number

    from (

        select a.Tagname,datepart(hour,a.[Datetime]) as [H], min(datepart(hour,b.[Datetime])) as [H2]

        from @History a

        inner join @History...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: using local variable with IN statement

    Another way

    select var1,var2

    from table1

    where charindex( ',' + var3 + ',' , ',' + @local + ',' ) > 0

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Previous months information

    quoteplease expalint the (convert(char(8),getdate(),120) + '01' )

    Convert allows you to convert dates to specific formats, eg style 120...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Previous months information

    select * from where datepart(m,datecolumn) = datepart(m,getdate()) - 1

    will select previous month on any day of the month

    but will result in either a table scan (or index scan...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Multiple Where Clause

    Similar to Kenneth's

    SELECT a.GroupID, a.GroupName, b.NoID, c.ContactNo, Datetime, Detination

    FROM [TableA] a

    INNER JOIN [TableB] b

    ON b.GroupID = a.GroupID

    INNER JOIN [TableC] c

    ON c.ContactNo = b.ContactNo

    WHERE a.GroupID...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: DECIMAL Data Type Question

    They will both use 9 bytes as you stated but

    (17,3) will only allow a maximum of 14 digits to the left of the decimal point

    (19,3) will allow 16

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Looping query Parent and child, and childs childs ......

    The only way I have achieved this is to use temp tables and a loop

    In what format do you want the output?

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Moving Data between Text fields

    SUBSTRING is limited to the maximum string length in sql (8000 less any overhead)

    why not just update one table directly from the other like this

    UPDATE p

    SET p.[Description] = d.[Description]...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: General Question SQL

    GROUP BY

    divides the data into groups and produces a list of unique values (like DISTINCT) and allows counting, summation etc

    so

    select col1 from test group by col1

    will produce the same as

    select...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: General Question SQL

    Duplicate post !

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Dynamic Query HELP!

    The data will need an identity column to specify the order of concatenation (or does this not matter?)

    If the table has an identity column (eg rowid) then try

    create table [mytable]...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Union query problem

    If I understand correctly and if both tables have the same number and type of columns then this

    SELECT ID1, ID2, col1, col2, colx

    FROM [table1]

    UNION

    SELECT ID1, ID2, col1,...

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 2,491 through 2,505 (of 3,544 total)