Read only query

  • Are there any way in t-sql to make a recorset read only. The users should not be able to edit the result

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • This has nothing to do with T-SQL.

    By default, any SELECT statement returns a recordset that is 'read only'. Only if you are using a cursor, you can change the data.

    It is the client stuff like ADO that makes it a recordset with browse and update/delete functionality. Most client libraries support some sort of 'read only' property for the Recordset object.

    A cursor is made read-only by using the FOR READ ONLY clause in your cursor definition.

    If possible, you can also use the built-in security features of SQL server by only granting SELECT and revoking UPDATE and DELETE permissions on the tables.

    Edited by - NPeeters on 10/02/2003 07:20:20 AM

  • Perhaps I wasn't clear enough. I was wondering if there are any overview of when SQL EM sets the recordset to read only.

    Ex: SELECT DISTINCT TblName FROM TABLE1.

    If I run this in EM, I'm not able to edit the fields, but when I'm not using the distinct - I can edit the fields. Are there any overview when a recordset is read only.

    I know of these now:

    Disitnct

    Union

    Pass through

    SUM

    AVG

    - Lars


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • If you want people to use EM then give them only read rights. Look up SQL server security in BOL

    To do it for one view only do select * from table with(nolock), although they will still be able to write directly to the source table if they have EM

    Keith Henry

    DBA/Developer/BI Manager




    Keith Henry



    According to everyone I know I "do something with computers?" for a living, so there you go.

  • The "read only" flag as you want to implement is application specific. i.e. in you enduser app (VB, Delphi, C#...) you have to define you recordset or data grid as read only.

    If you want to implement a general way let's do like Keith suggested. Don't grant any insert/update/delete rights.

    I personnaly do not give access to EM to my users.

    EM is as the name says: Enterprise Manager and not Application Query Tool

    Bye

    Gabor



    Bye
    Gabor

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply