Forum Replies Created

Viewing 15 posts - 13,336 through 13,350 (of 13,841 total)

  • RE: Changing Databases within a query

    You need to switch context as part of the sp_executesql statement.  Try this:

    declare @strSQL nvarchar(1000)

    set @strSQL = N'use tempdb '

    set @strSQL = @strSQL + N'select top 10 * from information_schema.columns'

    exec...

  • RE: Compare two tables and return unique data?

    Noticed that col_Fname is ambiguous, so you need to qualify it:

    SELECT DISTINCT r.col_Fname

    FROM tbl_Reports r left join tbl_Employees e

    ON r.col_Fname = e.col_Fname

    WHERE e.col_Fname is null

    If that doesn't work, there's something you're...

  • RE: Compare two tables and return unique data?

    Or this way:

    SELECT DISTINCT col_Fname

    FROM tbl_Reports r left join tbl_Employees e

    ON r.col_Fname = e.col_Fname

    WHERE e.col_Fname is null

    Using != in a join is an advanced technique that will rarely be required.  I...

  • RE: Need Help by Update Table !

    Hi Thomas - as I was writing my last post, I noticed that Remi had already written almost exactly what I was typing - so he "beat me to it" ie...

  • RE: Compare two tables and return unique data?

    Which fields need to be compared?  Just an ID field, or several?

  • RE: Need Help by Update Table !

    Beat me to it Remi!

  • RE: How do I avoid dead lock from "select" queries

    Check out SET TRANSACTION ISOLATION LEVEL in BOL and see whether that gives you what you want.

  • RE: Join tables and INSERT

    So does

    select o.OfficeID, d.DeptID, s.SectionID

    from offices o join depts d on o.OfficeID = d.OfficeID join Sections s on d.DeptID = s.DeptID

    Give you the results you want to insert to table4?

  • RE: Null value is eliminated by an aggregate or other SET operation

    Assuming that you want any NULLs to be summed as zeroes, use the isnull() function to get rid of the worrying error:

    select client,productcode,modifiedlot,location,sku,count(*) ct,cast(sum(isnull(grosswgt,0)) as decimal(18,4)) grosswgt,

      cast(sum(isnull(netwgt,0)) as decimal(18,4))...

  • RE: Join tables and INSERT

    What is the relationship between the first three tables?  Insertion is performed through use of the INSERT statement, believe it or not

    Here's an example:

    INSERT...

  • RE: Probably a very simple question.

    Hey, it's not as easy as you might think.  Try this (untested):

    update m1

    set SettingValue = 'True'

    from ModuleSettings m1

    where exists (select m2.ModuleID from ModuleSettings m2 where m2.SettingName = 'GroupType' and m2.SettingValue...

  • RE: Trigger not firing

    Good tip

  • RE: Problems with Alter Table and Update in DTS

    The top three lines appear to be duplicated for some reason - not that it matters.

    To make this more manageable, I suggest that you implement this as a stored procedure...

  • RE: auto incremental field

    Remember that such a trigger probably needs to deal with the insertion of multiple rows - a tasty bit of coding that might require a cursor.  Recommend that you stay...

  • RE: How to read from a table that is ''''passed in'''' as a parameter

    How about putting the whole statement in one string and then executing that?  Something like this:

    create procedure TestInputTable (@InputTable varchar(100))

    as begin

     declare @strSQL varchar(8000)

     set @strSQL= 'select * into #TempTable from '...

Viewing 15 posts - 13,336 through 13,350 (of 13,841 total)