Forum Replies Created

Viewing 15 posts - 226 through 240 (of 267 total)

  • RE: Query question

    For completeness we might add the EXISTS method.

    SELECT sg.sysusergroup_id, sg.sysusergroup_name

    FROM sysusergroup sg

    WHERE NOT EXISTS(

     SELECT * FROM sysuser_sysusergroup susg

     WHERE susg.sysuser_id = '1' AND sg.sysusergroup_id = susg.sysusergroup_id&nbsp

    Performancewise the...

  • RE: Query question

    SELECT sg.sysusergroup_id, sg.sysusergroup_name

    FROM sysusergroup sg

    WHERE sg.sysusergroup_id NOT IN(

     SELECT susg.sysusergroup_id

     FROM sysuser_sysusergroup susg

     WHERE sysuser_id = '1' )

    Just as an alternative to the outer join technique.

    /rockmoose

  • RE: Dynamic Total?

    No You cannot.

    An accumulated sum measure measure might provide some of the functionality you require. Also You could add a "quarter" level in your time dimension.

    /rockmoose

  • RE: How to identify rows having the same values in 4 columns ?

    All the t2.e = "john" records in t2 with a,b,c,d fields not equal to a,b,c,d fields in t1

    /rockmoose

  • RE: How to identify rows having the same values in 4 columns ?

    Better if You only want to list the distinct values of col1, col2, col3, col4.

    A join or exists clause is still necessary if You want to list all the rows...

  • RE: How to identify rows having the same values in 4 columns ?

    Actually I thought Antares response made good sense as answer to your question

    Probably you are trying to find duplicate records.

    ( Consider putting...

  • RE: How a procedure call procedure variable

    Use a Function:

    select ID, dbo.fn_return_name_recordset(ID) as name

    from nameTable

    where nameTable.ID='1000'

    /rockmoose

  • RE: Alternative method to identity

    Alternative approach is to have an Identity column, just for generating the identity number.

    Then have a computed column:

    (substring('0000000000',1,(10 - len([identity_col]))) + ltrim([identity_col])).

    The computed column would hold the "formatted" identity nymber.

    You...

  • RE: How could I copy several tables from one owner to other in the same database

    Ok,

    -- First case, generate same objects with new owner

    Use Steve Jones script + search and replace method. Just make sure that in QA -> Tools -> Options -> Script You...

  • RE: Append tables to view

    select sc.text

    from sysobjects so join syscomments sc on so.id = sc.id

    where so.name = 'vaProctime'

    -- and type = 'V'

    But imho it would probably be easier to generate the whole

    "ALTER VIEW dbo.table

    select...

  • RE: count(*) problem

    Syntax Error, Not surprising 😉

    One way:

    select vcFname, x.cnt

    from

     (  select fk_intprojectID, count(*) as cnt

      from tbl_ProjectsResearchers PR

      group by fk_intprojectID ) as x

     join tbl_Projects on x.fk_intprojectID = pk_intProjectID

    where x.cnt > 0

    Also the x...

  • RE: Filtering by time after date

    One way:

    select

     case

     when datepart(hour,tran_date) between 9 and 9 then '9am-10am (Morning)'

     when datepart(hour,tran_date) between 12 and 13 then '12-2pm (Lunch)'

     when datepart(hour,tran_date) between 17 and 18 then '5pm-7pm (Dinner)'

     else 'Not morning, lunch, dinner'...

  • RE: How could I copy several tables from one owner to other in the same database

    If You only want to change the owner of the tables, take a look at:

    sp_changeobjectowner

    ( Also read the Remarks in BOL for this proc, concerning permissions for the changed objects(tables...

  • RE: Deceptively hard - xfering single records to another database

    Hi,

    Since You are already using dynamic sql for this, generating explicit field names should be a no problem :-).

    I would go for Razvans suggestion and use the nifty "field name...

  • RE: Deceptively hard - xfering single records to another database

    You could use a global temporary table. ##table.

    declare @sql as varchar(500)

    set @sql = 'Select * into ##tmpClient from ' + @dbSource + '.dbo.Clients where ID = '...

Viewing 15 posts - 226 through 240 (of 267 total)