Forum Replies Created

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

  • RE: Date range issues

    The UNIONS are test data! (Read the comments.)

    Just use the query and replace the test tables with your tables.

  • RE: Date range issues

    -- *** Test Data ***

    DECLARE @t1 TABLE

    (

    &nbsp&nbsp&nbsp&nbspInitials varchar(10) NOT NULL

    &nbsp&nbsp&nbsp&nbsp,EffectiveDate datetime NOT NULL

    &nbsp&nbsp&nbsp&nbsp,RatePerHour money NOT NULL

    )

    INSERT INTO @t1

    SELECT 'aaaa', '20050101', 150 UNION ALL

    SELECT 'aaaa', '20050705', 200 UNION ALL

    SELECT 'aaaa', '20050901',...

  • RE: Left outer join in where clause

    Without the rest of your tables (P as in P.Tran_ID?) and the rest of the WHERE clause, your post does not make sense.

  • RE: Dead lock issue

    Try:

    INSERT INTO table_geography

    SELECT @geolevel

    WHERE NOT EXISTS

    (

    &nbsp&nbsp&nbsp&nbspSELECT *

    &nbsp&nbsp&nbsp&nbspFROM table_geography G WITH (UPDLOCK )

    &nbsp&nbsp&nbsp&nbspWHERE G.geolevel = @geolevel

    )

  • RE: Uploading Tiff files using SQL 2005 and not using any application

    I have a note that the following should work in 2005. (I must have seen it on a forum somewhere.) I have never tried it as ADO/ADO.Net seems less hassle.

    CREATE...

  • RE: I don't want SQL Server to order the data

    Gail is right to say that order is meaningless in a SQL table, however order does have meaning in your Excel worksheet. In order to retain this order in SQL...

  • RE: multiple nested select statments in 1 query

    JReed,

    I find all the unneeded brackets in code makes it difficult to read. I have reformatted it as follows:

    SELECT DISTINCT

    &nbsp&nbsp&nbsp&nbspAccounts.UID

    &nbsp&nbsp&nbsp&nbsp,Accounts.Fname + ' ' + Accounts.MI AS Fname

    &nbsp&nbsp&nbsp&nbsp,Accounts.Lname...

  • RE: NOT IN condition

    Your queries are running correctly, NOT IN and NOT EXISTS are not the same when there are NULLs involved and ANSI_NULLs are on. (Your data must have NULLs in the...

  • RE: HashBytes Function - Change varbinary output

    Try casting to bigint and using the fnNumber2AnyBase function at the following link.

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87871

  • RE: need help in query

    Conceptually in SQL the FROM clause is evaluated first and then the results are filtered by the WHERE clause.

    Think about what you are doing! Will NULL = 46 ever be...

  • RE: Converting a query with *= to ansi conform join operators

    As the kl filters are after the join in the where clause, I suspect the following:

    SELECT ma_idx, ma_kurztext_deu, kd.kd_preis, kl.kd_preis

    FROM debitor D

    &nbsp&nbsp&nbsp&nbspJOIN kondition kd

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspON D.db_ko_vkpreis = kd.kd_pl_idx

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspAND D.db_vkorg = kd.kd_vkorg

    &nbsp&nbsp&nbsp&nbspJOIN...

  • RE: Finding a substring within a text

    You will never get an exact way to sort out the duplicates but I would approach it as follows:

    1. Write a Longest Common Substring function. (Google for algorithm outlines) This...

  • RE: complex select problem w history tables, date ranges

    Without some sample data it is difficult to tell what you want.

    Maybe something like:

    SELECT U1.UserNew

    &nbsp&nbsp&nbsp&nbsp,D.TelNumber

    &nbsp&nbsp&nbsp&nbsp,D.ChangeDate AS DeviceDate

    &nbsp&nbsp&nbsp&nbsp,D.IMEInew

    FROM DeviceHistory D

    &nbsp&nbsp&nbsp&nbspJOIN (

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspUserHistory U1

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspLEFT JOIN UserHistory U2

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspON U1.TelNumber = U2.TelNumber

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspAND U1.UserNew = U2.UserOld

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspAND...

  • RE: Min() Max() and joining fields

    You could try something horrible like:

    DECLARE @TimeFrom datetime

        ,@TimeTo datetime;

    SELECT @TimeFrom = DATEADD(mi, -1, MAX([TimeStamp]))

            ,@TimeTo = MAX([TimeStamp])

    FROM dbo.DemandSpread;

    SELECT

        D1.MinER2BidPrice

        ,D2.MinER2DSTotal

        ,D1.MaxER2BidPrice

        ,D3.MaxER2DSTotal

        ,D1.MinESBidPrice

        ,D4.MinESDSTotal

        ,D1.MaxESBidPrice

        ,D5.MaxESDSTotal

    FROM (

            SELECT MIN(S1.ER2BidPrice) AS MinER2BidPrice

                ,MAX(S1.ER2BidPrice) AS MaxER2BidPrice

                ,MIN(S1.ESBidPrice) AS MinESBidPrice

                ,MAX(S1.ESBidPrice) AS MaxESBidPrice

            FROM dbo.DemandSpread S1

            WHERE S1.[TimeStamp]...

  • RE: Using LIKE

    or you could try something like:

    SELECT *

    FROM YourTable T

        JOIN (

                SELECT '98101' UNION ALL

                SELECT '98104' UNION ALL

                SELECT '98154'

            ) D (ZIP)

            ON T.ZIP LIKE D.ZIP + '%'

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