Forum Replies Created

Viewing 15 posts - 1,306 through 1,320 (of 1,491 total)

  • RE: Row count in data range

    How about:

    SELECT [ID]

            ,COUNT(CASE WHEN Value BETWEEN 0 AND 9 THEN 1 END) AS [0_9]

            ,COUNT(CASE

  • RE: xp_cmdshell can''''t execute VBS

    Maybe something like the following will work:

    Set WshShell = WScript.CreateObject("WScript.Shell")

    WshShell.Run("""c:\program files\internet explorer\iexplore.exe"" http://www.yahoo.com")

     

  • RE: Error Handling Within a Transaction

    Sorry if I seemed a little hard, but I have seen code like this cause too many problems.

    On the question of the results, it is difficult for anyone to comment...

  • RE: Error Handling Within a Transaction

    This is NOT the best approach to take for this type of problem. It is best to use a set based approach with the data either being cleansed first or...

  • RE: calculating date & time difference from 4 text fields

    If possible, change the dates and times to use datetime.

    Also, how are you going to define a month? For days, hours and minutes the following should work:

    SELECT D.MiDiff/1440 AS...

  • RE: How to find rows that need to be nvarchar

    Try casting the column to varchar(n) and then back to nvarchar(n) and seeing if it is the same.

    SELECT YourNVarCharColumn

    FROM YourTable

    WHERE YourNVarCharColumn <>

            CAST(CAST(YourNVarCharColumn as varchar(<collength&gt

  • RE: Query Help

    Your example output does not seem to make much sense. You may want something along the lines of:

    -- *** Start of test data ***

    DECLARE @t TABLE

    (

     UserID int NOT NULL PRIMARY...

  • RE: Working around DATEDIFF when "date" = ''''00000000''''

    Is this what you want?

    WHERE 1 =

     CASE

     WHEN NULLIF(NEWREQDATE, '00000000') IS NULL AND NULLIF(ORIGREQDATE, '00000000') IS NULL

     THEN 0

     WHEN NULLIF(NEWREQDATE, '00000000') IS NULL

      AND DATEDIFF(d, CAST(ORIGREQDATE AS datetime), GETDATE()) > 1

     THEN 1

     WHEN NULLIF(NEWREQDATE,...

  • RE: Transaction inside a cursor?

    Your second SP still uses a pseudo cursor.

    You should really look at writing set based code. To do this one needs to know the DDL (CREATE TABLE with PKs and...

  • RE: Slow performing query

    Something else you could try is explicitly specifying the type of join.

    When there are more than 3 or 4 tables in a query I have noticed that the optimizer works...

  • RE: Transaction inside a cursor?

    I doubt if you need to use a cursor for this. Why not just do a batch insert of everything in the correct order with the INSERT queries getting rid...

  • RE: JOIN vs =*

    P.S. I did my guess conversion using the WHERE clause on the following basis:

    1. moving the INNER JOINs to the top. (The only INNER JOIN was there already.)

    2. converting all...

  • RE: JOIN vs =*

    It has been some time since I have converted outer joins from old style to new style format, however there are generally two points to bear in mind:

    1. With the...

  • RE: how to denormalize in query?

    You need to SUM the CatchNumber. Something like the following should work:

    SELECT A.ShipName, A.FishingDate, A.FishingLocation, D.Jack, D.Rose

    FROM TABLE1 A

     JOIN (

      SELECT B.ShipName

       ,B.FishingDate

       ,SUM(CASE B.FishSpecies WHEN 'Jack' THEN CatchNumber END) AS Jack

       ,SUM(CASE B.FishSpecies...

  • RE: Help with Select Top 1

    BOL gives good documentation on locking. In brief it appears you were confused between the lock granularity,  ROWLOCK, PAGLOCK, TABLOCK etc and the lock type, shared, UPDLOCK, XLOCK etc.

    In your...

Viewing 15 posts - 1,306 through 1,320 (of 1,491 total)