SQL Server Performance

How to specify a query as read only

Discussion in 'SQL Server 2005 General Developer Questions' started by dhana1706, Sep 4, 2008.

  1. atulmar New Member

    I think INSTEAD OF trigger would be cheaper in cost than AFTER trigger.
  2. Adriaan New Member

    You might try adding DISTINCT or GROUP BY to the view, that usually makes the resultset uneditable in client apps.
  3. Madhivanan Moderator

    [quote user="Adriaan"]
    You might try adding DISTINCT or GROUP BY to the view, that usually makes the resultset uneditable in client apps.
    [/quote]
    or by adding a computed column
  4. atulmar New Member

    I would rather not add distinct or group by to view definition. Computed column would work faster in this case, we can take smallest computaion to make it light weight.
  5. yossi New Member

    The computed column worked like a charm. Now I don't need triggers![:D]
  6. Madhivanan Moderator

    <P mce_keep="true">[quote user="yossi"] <P>The computed column worked like a charm.&nbsp; Now I don't need triggers!<IMG alt="Big Smile" src="http://sql-server-performance.com/Community/emoticons/emotion-2.gif"></P><P>[/quote]</P><P>You are welcome [:)]</P>
  7. Zippy New Member

    Maybe not quite what you are looking for but you can have a view where two different users see different things depending on their scheme.CREATE
    VIEW [dbo].d1 AS select col1, col2, col3 from tablenameCREATE
    VIEW [guest].d1 AS select col1, col2 from tablenameEXECUTE
    AS LOGIN ='regularuser'
    SELECT * FROM d1
    REVERT
    EXECUTE AS LOGIN ='guestuser'
    SELECT * FROM d1
    REVERT

Share This Page