• Here's an interesting bit of code you can try:

    CREATE TABLE #Doctors

    (ID INT IDENTITY, Name VARCHAR(100), Practice VARCHAR(100), [Views] INT)

    CREATE TABLE #DoctorInfo

    (Name VARCHAR(100), OfficeDays VARCHAR(10))

    INSERT INTO #Doctors

    SELECT 'Dr. Dwain', 'Gynecology', 0 UNION ALL SELECT 'Dr. Jeff', 'General Practitioner', 0

    INSERT INTO #DoctorInfo

    SELECT 'Dr. Dwain', 'Monday'

    UNION ALL SELECT 'Dr. Jeff', 'Tuesday'

    UNION ALL SELECT 'Dr. Dwain', 'Tuesday'

    UNION ALL SELECT 'Dr. Jeff', 'Wednesday'

    GO

    UPDATE d

    SET [Views] = [Views] + 1

    OUTPUT INSERTED.*, a.OfficeDays

    FROM #Doctors d

    INNER JOIN #DoctorInfo a ON a.Name = d.Name

    WHERE ID = 1+ ABS(CHECKSUM(NEWID())) % 2

    GO 5

    SELECT * FROM #Doctors

    DROP TABLE #Doctors, #DoctorInfo

    If you can't figure out what it is doing let me know and I'll explain. But strangely you can dump the information from JOINed tables in the OUTPUT clause.

    You cannot however, add any JOINs after the composable DML solution I suggested.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St