Forum Replies Created

Viewing 15 posts - 196 through 210 (of 430 total)

  • RE: Join SQL needed to Update column

    I don't think that would work david. Let us try to add few more rows in TBL_A and TBL_B. It would be impossible unless there is a definite way to...

  • RE: Left outer Query optimization

    Can you post the full query. Posted query and the following would give the same result set.

    SELECT DISTINCT [Baseball65K24].[Col005])

    FROM

     [Baseball65K24]

    LEFT OUTER JOIN

     [Baseball65K50]

    ON

     [Baseball65K50].[Col007] =  [Baseball65K24].[Col005]

    WHERE

     [Baseball65K50].[Col007] IS NULL

    ORDER BY

     [Baseball65K24].[Col005]

    Also what is the...

  • RE: Update problem

    As Remi mentioned design can be different and better.

    Anyway for existing design updating using a loop will be a performance problem for large data rows. I would do it like

    SET...

  • RE: joining on a table twice

    This design will take more stages

    SET NOCOUNT ON

    DECLARE @dataTable TABLE

    (

    RowID  INT IDENTITY,

    CaseNo  INT,

    StageStatus  INT

    )

    INSERT @dataTable (CaseNo, StageStatus)

    SELECT 1, 1 UNION ALL

    SELECT 1, 2 UNION ALL

    SELECT 1, 2 UNION ALL

    SELECT 1, 2 UNION ALL

    SELECT 1, 3 

    DECLARE @statusTable...

  • RE: joining on a table twice

    SET NOCOUNT ON

    DECLARE @dataTable TABLE

    (

    CaseNo  INT,

    Stage1Status  INT,

    Stage2Status INT,

    Stage3Status INT

    )

    INSERT @dataTable

    SELECT 1, 2, 2, 3

    DECLARE @statusTable TABLE

    (

    stageValue INT,

    stageName  VARCHAR(100)

    )

    INSERT @statusTable

    SELECT 1, 'Not started' UNION

    SELECT 2, 'Processing' UNION

    SELECT 3, 'Completed'

     

    SELECT A.CaseNo,

     B.stageName,

     C.stageName,

     D.stageName

    FROM

     @dataTable A

    JOIN

     @statusTable B

    ON

     A.Stage1Status = B.stageValue

    JOIN

     @statusTable C

    ON

     A.Stage2Status =...

  • RE: Join SQL needed to Update column

    How do you relate '12345' ID in Table B with '666888' ID in Table A

  • RE: Converting text to datetime

    This will work. I am not sure about a way to convert into datetime without a space between date and time in T-SQL.

    SET NOCOUNT ON

    DECLARE @myTable Table

    (

    MyDateString VARCHAR(20)

    )

    INSERT @myTable

    SELECT '2005081607:58:26:170' UNION

    SELECT...

  • RE: Converting text to datetime

    You miss a space between date and time

     

    DECLARE @MyDate DATETIME

    SET @myDate = '20050816 07:58:26:170'

    SELECT CONVERT(DATETIME, '20050816 07:58:26:170') WithConvert, @myDate Implicit

  • RE: Multiple inserts

    Adding a parameter is done with

    Set MyParam = SERVER.CREATEOBJECT ("ADODB.Command")

    MyParam.Name = "@SRhospitalCanvass"

    MyParam.Value = SRhospitalCanvass

    MyParam.Size = 10

    MyParam.Direction = adParamInput

    MyParam.Type = adChar

    MyCmd.Parameters.Append MyParam

    This can be done in one line like to...

  • RE: Pivot Report - Dynamic Columns

    Thank You Wayne Lawton I did the solution similar to that. I thought there might be a way other than dynamic query. I...

  • RE: Count Versions

    Do you miss a

    and a.softname = b.softname in the query

    select  a.editor, a.softname, a.version, count(a.hostname)total,

     case when suite = 0 then 'NO'

     ELSE 'YES'

     END AS Suite

    from SLIB_RESULTS a

    join (select max(version)...

  • RE: Fetch a row in a table.

    If this is what you want.

    HTH

    SET NOCOUNT ON

    DECLARE @MyTable TABLE

    (

    MyName VARCHAR(10),

    MyNum   INT

    )

    INSERT @MyTable

    SELECT 'AAA',    555 UNION

    SELECT 'BBB',    888 UNION

    SELECT 'CCC',    999 UNION

    SELECT 'DDD',    777 UNION

    SELECT 'EEE',    888 UNION

    SELECT 'TTT',   ...

  • RE: Fetch a row in a table.

    This will fetch a row but not the row in a row position. For that we must specify a where condition.

    SET ROWCOUNT 1

    SELECT * FROM myTable

    OR

    SELECT TOP 1 * FROM...

  • RE: Need help w/ Case statement

     

    SET NOCOUNT ON

    DECLARE @BL_TRUCK_BOL_DEST TABLE

    (

    bol_no  VARCHAR(10),

    dest_bol_no VARCHAR(10)

    )

    INSERT INTO @BL_TRUCK_BOL_DEST VALUES ('00001', '2BT')

    INSERT INTO @BL_TRUCK_BOL_DEST VALUES ('00001', '1BT')

    INSERT INTO @BL_TRUCK_BOL_DEST VALUES ('', '4BT')

    INSERT INTO @BL_TRUCK_BOL_DEST VALUES ('', '5BT')

    DECLARE @bol_no VARCHAR(10)

    DECLARE @dest_bol_no VARCHAR(10)

    SELECT @bol_no =...

  • RE: SELECT from multiple tables

    Yes I was about to tell if there is no relationship then for each row in clientmaster  all the rest of the rows will be repeated.

    Why do you...

Viewing 15 posts - 196 through 210 (of 430 total)