Forum Replies Created

Viewing 8 posts - 46 through 53 (of 53 total)

  • RE: LEFT OUTER JOIN if True INNER JOIN if False

    Hi guys,

    My apologies, just realized that I pretty much repeated code already posted by someone else (never do things in a hurry!).

    MB

  • RE: LEFT OUTER JOIN if True INNER JOIN if False

    LOL

    Just realized, my previous post is same as:

    select a.UserId,a.columnA,a.ColumnB from tableA a

    left outer join FlaggedRecords b

    on a.USerId=b.USerId

    where ((@Flag=0 ))

    Or

    (@Flag=1 and b.UserId is not null)

    Even easier!

  • RE: LEFT OUTER JOIN if True INNER JOIN if False

    Hi,

    I believe that htis will solve your problem:

    select a.UserId,a.columnA,a.ColumnB from tableA a

    left outer join FlaggedRecords b

    on a.USerId=b.USerId

    where ((@Flag=0 and b.UserId is null) or (@flag=0 and b.USerId is not...

  • RE: algorithm for best fit function

    Hi

    I could not really see how does this relate to SQL Server or TSQL, but let's give it a try...

    Please, note that this is not the complete solution but the...

  • RE: Stored procedure with parameters not working

    Hi

    You could also use:

    execute sp_MSforeachDB @command1="use [?] select * from dbo.sysobjects where xtype='U'"

    Keep in mind that system databases will be listed as well, although I don't think that should be...

  • RE: query suddenly goes slow - Worktable logical reads high

    Try to rebuild the indexes on the tables that are used in that query

    (If it suddenly starts working slower and recompiling doesn't help, set statistics io shows big numbers it...

  • RE: Help Needed

    Additionally,

    This (is not very elegant, I know) would return records from your example

    DECLARE @tbl TABLE (Id INT , [Name] char(3), Lft INT , Rit INT , ParentId INT )

    INSERT @tbl...

  • RE: Help Needed

    Hi

    Your query is returning ALL the left nodes, starting from node 1. (matches description of what you want)

    Based on your example it seems that you want FIRST LEFT NODE to...

Viewing 8 posts - 46 through 53 (of 53 total)