Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Friday, March 30, 2012

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I get the following error message when I select a report:

  • An error has occurred during report processing.

  • Cannot create a connection to data source 'PSS5'.
  • Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

    My Data source is set to Windows Integrated Security when I get this error message. If I change my data source to be "Credential supplied by the user running the report", the report generates fine. I am running SQL 2005 SP2. I have SQL reporting services installed on different server than my database services. Both servers are W2K3 R2 x64.


  • My IIS website and virtual directories are set up for Integrated Windows Authentication. My IIS application pool is set up to use an AD service account. I have followed the step/procedures outlined at: http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/security/tkerbdel.mspx

  • http://blogs.msdn.com/sql_protocols/archive/2005/10/12/479871.aspx
    http://blogs.msdn.com/sql_protocols/archive/2006/08/10/694657.aspx

  • but to no avail. I am sure that I am missing something, but I can't figure out what. I would like to use Integrated Authentication, any ideas?

    You are using allow anonymous in IIS. This means that your ReportViewer control is not passing the users credentials to the report server. If you want to use "allow anonymous" you will need to pass valid credentials to the report server. This can be done in your code that calls the Report Viewer control/Report Server.|||

    Hi,

    see more information about passing credentials programmatically here:

    http://blogs.msdn.com/bimusings/archive/2005/11/05/489423.aspx

    HTH, Jens K. Suessmeyer.

    http://www.sqlserver2005.de

    |||

    I don't think that the problem is related to ReportViewer or IIS configuration (Since the credantial information is passed to the datasource and denied). When u select Windows Intedrated Security for report options, the credantials of the user that initiates the Reporting Services at every start up (by default this user is: 'NT AUTHORITY\ANONYMOUS LOGON') are sent to the datasource (And if this user is not authorized in the target database you get the following error).

    You can authorize the Reporting Services user in the target database ('NT AUTHORITY\ANONYMOUS LOGON' exists within your SQL Server Machines Users.

    or

    You can change the Reporting Services' user to a domain user that both computers can authanticate.

    Administrative Tools -> Services. (Find 'SQL Server Reporting Services (MSSQLSERVER)' change user from LOG ON tab.)

    I hope this helps.

    |||Thanks for the replies, but they didn't seem to help. To clear up a few questions, this report was developed in Visual Studio 2005 and it works fine in it. The report renders ok if I launch in on the server, but not anywhere else. My Reporting Services' user is an AD account that both my servers can authenicate against, and this user does have access to the DB. My Website and virtual directories have "allow anonymous access" unchecked.|||I decided to try one more thing. I went into the web.config file and changed the <identity impersonate="false"/> and that fixed it for me. Thanks for all the replies.|||

    Note:

    The above fix will force IIS to use the Application pool account to connect to SQL on the remote server.

    This is still not the permanent solution that I am looking for, I believe my problem is a kerberos issue at this point. Any tips/hints/suggestions on troubleshooting this problem would be helpful.

    sql
  • Wednesday, March 7, 2012

    Logical functions in SELECT clause

    Hi,

    this ought to be elementary: I want to select the logical inverse of a bit type column. The online help tells me

    Syntax [ NOT ] boolean_expression
    Arguments

    boolean_expression

    Is any valid Microsoft? SQL Server? Boolean expression.

    Result Value

    NOT reverses the value of any Boolean expression.

    The way I read this I should be able to then simply SELECT NOT bit_col, yet I get a syntax error when I try to do simply

    SELECT (NOT CAST(1 AS BIT))

    Arrrrgh! I've tried some syntactical variations on the theme, but it seems the not function just doesn't work in the SELECT clause, only in the WHERE clause.

    Of course, I can get the result I want using

    select case bit_col when 1 then 0 else 1 end as 'inverted_bit_col';

    But, is there really no more elegant and well-performing way to select an inverted bit column than using a CASE?

    Hi

    I have tried ^ (Bitwise Exclusive OR) with 1 and it worked.

    CREATE TABLE #tmp ( bitNumber BIT NOT NULL )

    INSERT INTO #TMP VALUES (1)
    INSERT INTO #TMP VALUES (0)

    SELECT bitNumber, bitNumber ^ 1 FROM #TMP

    The values in (bitNumber ^ 1 ) are reversed from bitNumber

    NB.

    |||Note that the bit field, although commonly used as a boolean field, is a bit field and holds values of 1 and 0, not true and false (although in most programming languages these values are interchangeable). But, as far as I know, a bit field does not evaluate to a boolean expression, and thus cannot be used as such. What you want is to use a bitwise operator as illustrated well above. Someone please correct me if I am wrong in this assumption.|||

    But, is there really no more elegant and well-performing way to select an inverted bit column than using a CASE?

    Define elegant and well-performing? Are you having performance problems with:

    select case bit_col when 1 then 0 else 1 end as 'inverted_bit_col'

    I can't see it being a performance question, and truthfully it is as elegant as any other way of doing it (a function would be better, so you might write a CLR function to do it, but it would be overkill. I like this way because it is clear what you are doing. you can also us the modulus function to "flip the bit":

    (@.bit + 1) % 2

    I tried each way using the following test ant the results were very much the same result.

    set nocount on
    create table testBit
    (
    bitCol bit
    )
    go
    insert into testBit
    select cast( case when rand() < .5 then 0 else 1 end as bit)
    go 400000 --works in 2005. For 2000 you will need to write a loop

    DBCC FREEPROCCACHE
    declare @.getdate datetime
    set @.getdate = getdate()
    declare @.test table (bitCol bit)
    insert into @.test
    select (bitCol + 1) % 2
    from testBit
    select datediff(ms,@.getdate,getdate()) /1000.0 as [seconds (bitCol + 1) % 2]
    go
    DBCC FREEPROCCACHE
    declare @.getdate datetime
    set @.getdate = getdate()
    declare @.test table (bitCol bit)
    insert into @.test
    select (bitCol ^ 1 )
    from testBit
    select datediff(ms,@.getdate,getdate()) /1000.0 as [seconds (bitCol ^ 1 )]
    go
    DBCC FREEPROCCACHE
    declare @.getdate datetime
    set @.getdate = getdate()
    declare @.test table (bitCol bit)
    insert into @.test
    select case bitCol when 1 then 0 else 1 end
    from testBit
    select datediff(ms,@.getdate,getdate()) /1000.0 as [seconds case bitCol when 1 then 0 else 1 end]
    go

    Not scientific, but it does show that there is very little differnece between the different styles.

    |||XOR does the trick, yes. Thanks!|||

    I get it; in SQL Server, bit is not boolean. When I connect using ADO.NET (SqlClient, the native provider) the bit type maps to boolean, and I short-circuited...

    How can I test (directly in query analyzer) what the type of the expression

    bit_col ^ 1

    is, when bit_col is of type bit? I still want the result to map to System.Boolean - I presume I'd have to cast the result as bit, but is there a way to make sql server tell me the type of an expression?

    Thanks for the tip!

    |||

    Thank you for a very informative and complete reply.

    I basically just held some prejudice against the case statements. I'm now wondering if that was completely without foundation...

    Thanks!

    |||

    well.. we all know from boolean algebra that XOR is much lighter then ADD and especially division by modulo and processing script's CASE

    It is my penny if we are talking about performance, let say we want to process 20 millions records :) I think the difference will be significant.

    |||You can invert a bit with the ~ operator.|||I gotta be honest with you. If you are twiddling bits over 20 million rows you have a lot more problems than whether CASE works faster than ~ or modulo, or the other one :)

    Logical constant in Select

    I can add a constant to any Select statement, SELECT 0 as xxx,* From XYZ, bu
    t
    how I can add a Logical constant?Hi,
    What do you mean by local constant ? Please make it clear
    Thanks
    Hari
    SQL Server MVP
    "Constantin Chionas" <constantinchionas@.hotmail.com> wrote in message
    news:B7ABAC44-4C44-4E74-A74F-F02B8944C58E@.microsoft.com...
    >I can add a constant to any Select statement, SELECT 0 as xxx,* From XYZ,
    >but
    > how I can add a Logical constant?|||Are you talking about a Boolean constant (i.e., True, False)? SQL Server 2K
    doesn't allow you to return a Boolean value in a result set. What you can
    do is use a CHAR flag ('T' or 'F') to represent your Boolean flag values, or
    one of the INTEGER types, or even a BIT (0/1).
    "Constantin Chionas" <constantinchionas@.hotmail.com> wrote in message
    news:B7ABAC44-4C44-4E74-A74F-F02B8944C58E@.microsoft.com...
    >I can add a constant to any Select statement, SELECT 0 as xxx,* From XYZ,
    >but
    > how I can add a Logical constant?|||Thank you all for your help,
    I guess after a lot of trying I reached to the same conclusion, I cannot
    return a Boolean value, so I guess I will use the BIT (0/1) as I am already
    doing, but I wanted to be sure that there is no other way.
    "Michael C#" wrote:

    > Are you talking about a Boolean constant (i.e., True, False)? SQL Server
    2K
    > doesn't allow you to return a Boolean value in a result set. What you can
    > do is use a CHAR flag ('T' or 'F') to represent your Boolean flag values,
    or
    > one of the INTEGER types, or even a BIT (0/1).
    > "Constantin Chionas" <constantinchionas@.hotmail.com> wrote in message
    > news:B7ABAC44-4C44-4E74-A74F-F02B8944C58E@.microsoft.com...
    >
    >|||I've heard that ANSI SQL99 includes Boolean types, but someone else would
    have to speak to whether they're included in SQL Server 2005 or not.
    "Constantin Chionas" <constantinchionas@.hotmail.com> wrote in message
    news:A09BE661-6E05-48ED-9D04-F986D93B98B5@.microsoft.com...
    > Thank you all for your help,
    > I guess after a lot of trying I reached to the same conclusion, I cannot
    > return a Boolean value, so I guess I will use the BIT (0/1) as I am
    > already
    > doing, but I wanted to be sure that there is no other way.
    > "Michael C#" wrote:
    >|||There is no logical datatype in SQL, nor do good SQL programmers write
    code that uses low-level bit flags. It sounds like you have serious
    design issues.|||Let's assume for the moment that we define a boolean data type to mean an
    integer limited to the values 0 and 1. Are you saying that all database doma
    in
    problems where this sort of value is used as a column is a de facto sign of
    poor
    design?
    Thomas
    "--CELKO--" <jcelko212@.earthlink.net> wrote in message
    news:1113230885.195828.320500@.g14g2000cwa.googlegroups.com...
    > There is no logical datatype in SQL, nor do good SQL programmers write
    > code that uses low-level bit flags. It sounds like you have serious
    > design issues.
    >|||>> Let's assume for the moment that we define a boolean data type to
    mean an integer limited to the values 0 and 1. Are you saying that all
    database domain problems where this sort of value is used as a column
    is a de facto sign of poor design? <<
    Does this encoding allow for easy expansion of value? Nope. Does this
    convention allow for interfaces to ANSI X3J programming languages which
    have a BOOLEAN or LOGICAL data type? Nope (Even Microsoft's
    proprietary languages use +1,0 and -1). Does it usually represent a
    computation rather than a simple scalar value? Yep! So you use a CASE
    expression in the SELECT list with that computation and a meaningful
    output. Most often, an event date or attribute value would provide
    more information than a simple low-level bit flag.|||> Does this encoding allow for easy expansion of value? Nope
    Clarify. What type of expansion? Do you mean from 0,1 to 0..n? That breaks t
    he
    domain restriction and thus evades the issue. The values are restricted to t
    wo
    values and perhaps a null. Are you suggesting that boolean-type columns (mea
    ning
    columns restricted to two values and perhaps a null) have no purpose whatsoe
    ver
    in any good database design?

    > Does this
    > convention allow for interfaces to ANSI X3J programming languages which
    > have a BOOLEAN or LOGICAL data type?
    An irrelevant example. If the database product you are currently using does
    not
    provide for the BOOLEAN or LOGICAL data type, then migrating to one that doe
    s
    will require a conversion regardless of your current approach. Clearly ANSI
    /ISO
    feels the necessity of providing for the declaration of a flag-type data typ
    e as
    they added it to the SQL99 specification.

    > Does it usually represent a
    > computation rather than a simple scalar value?
    Never use a noun when you can use a pronoun ;-> I'm not sure what "it" is an
    d
    I'm not sure what you mean by a "computation" as opposed to a simple scalar
    value. If you mean is the flag "calculable" as opposed to static, then presu
    me
    no.

    > So you use a CASE
    > expression in the SELECT list with that computation and a meaningful
    > output.
    Are you talking about converting said boolean value into a meaning value lik
    e
    Yes/No or True/False? I was under the impression that was the job of the
    reporting and/or presentation engines. It might display as Yes/No on one
    report/screen, a checkbox on another, Enabled/Disabled on another and so on.

    > Most often, an event date or attribute value would provide
    > more information than a simple low-level bit flag.
    How is it that this is "low-level"? Just because Microsoft used the word "bi
    t"?
    I could just as easily define a column as an Integer Check (Column In(0,1))
    and
    achieve the same result. The method with which the value is stored is, as yo
    u
    constantly remind everyone, an implementation detail.
    I come back to the original question. Does a boolean-type column (one that i
    s
    restricted to two values and perhaps null) have a place in database design?
    If
    the answer is yes, then techniques such as SQL's BIT data type are valid
    solutions to get around the fact that SQL 2000 does not provide for the BOOL
    EAN
    keyword and thus should not be criticized. There are valid reasons for not u
    sing
    a BIT field in SQL not the least of which is that you cannot include that co
    lumn
    in an index. However, that is an entirely different subject than precluding
    the
    use of boolean colums altogether. If boolean columns do not have a valid pla
    ce
    in database design, then I would numerous scenarios that I interested in kno
    wing
    how you would solve without a boolean.
    Thomas

    logical and

    Hi,
    I want to do a logical comparison between two tinyint-columns in a select
    statement.
    With logical I mean: if a bit in the tinyints are both 1 then comparison is
    true.
    00001000 and 11000001 = false
    10101010 and 00000010=true
    Can this be done in SQLServer?
    Thanks
    FrankThe bitwise AND logical operator in SQL Server is '&'. This expects integer
    values. Converting your binary values to integer:
    IF 8 & 193 = 193 PRINT 'true' ELSE PRINT 'false'
    IF 170 & 2 = 2 PRINT 'true' ELSE PRINT 'false'
    See Bitwize AND in the Books Online for more information.
    --
    Hope this helps.
    Dan Guzman
    SQL Server MVP
    "Frank" <frank@.frank.com> wrote in message
    news:41e50fbc$0$6211$e4fe514c@.news.xs4all.nl...
    > Hi,
    > I want to do a logical comparison between two tinyint-columns in a select
    > statement.
    > With logical I mean: if a bit in the tinyints are both 1 then comparison
    > is true.
    > 00001000 and 11000001 = false
    > 10101010 and 00000010=true
    > Can this be done in SQLServer?
    > Thanks
    > Frank
    >|||GREAT!!!!!
    Frank
    "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> schreef in bericht
    news:uaWOg4K%23EHA.1296@.TK2MSFTNGP10.phx.gbl...
    > The bitwise AND logical operator in SQL Server is '&'. This expects
    > integer values. Converting your binary values to integer:
    > IF 8 & 193 = 193 PRINT 'true' ELSE PRINT 'false'
    > IF 170 & 2 = 2 PRINT 'true' ELSE PRINT 'false'
    > See Bitwize AND in the Books Online for more information.
    > --
    > Hope this helps.
    > Dan Guzman
    > SQL Server MVP
    > "Frank" <frank@.frank.com> wrote in message
    > news:41e50fbc$0$6211$e4fe514c@.news.xs4all.nl...
    >> Hi,
    >> I want to do a logical comparison between two tinyint-columns in a select
    >> statement.
    >> With logical I mean: if a bit in the tinyints are both 1 then comparison
    >> is true.
    >> 00001000 and 11000001 = false
    >> 10101010 and 00000010=true
    >> Can this be done in SQLServer?
    >> Thanks
    >> Frank
    >>
    >|||Frank,
    Dan pointed you in the right direction, and I'll just note that
    to see if X and Y have a common bit set, compare X & Y
    with 0.
    Steve Kass
    Drew University
    Frank wrote:
    >Hi,
    >I want to do a logical comparison between two tinyint-columns in a select
    >statement.
    >With logical I mean: if a bit in the tinyints are both 1 then comparison is
    >true.
    >00001000 and 11000001 = false
    >10101010 and 00000010=true
    >Can this be done in SQLServer?
    >Thanks
    >Frank
    >
    >|||"Steve Kass" <skass@.drew.edu> wrote in message
    news:uB%23xjUL%23EHA.1188@.tk2msftngp13.phx.gbl...
    > Frank,
    > Dan pointed you in the right direction, and I'll just note that
    > to see if X and Y have a common bit set, compare X & Y
    > with 0.
    > Steve Kass
    > Drew University
    >
    If X & Y = 0 then you have no bits in common.
    X 1001
    Y 0110
    ====== 0000
    IF X & Y = Y then you have Y bits in common.
    X 1001
    Y 0001
    ====== 0001 <-- Same as Y
    IF X & Y > 0 then you have at lest some bits in common, but not necessarily
    all of them.
    X 1001
    Y 0011
    ====== 0001 > 0 At least one bit in common.
    Rick Sawtell
    MCT, MCSD, MCDBA

    Friday, February 24, 2012

    Logic statement using select query

    I'd like to make a logic statement, that would take as arguments result of the sql select query. In more details: I would like to create a local Bool variable that would be false if some value is NULL in the table (or select query).

    Query example:

    select taskID from Users where Login=@.username

    Which classes/methods should i use to solve this problem? I use SqlDataSource to get access to database and i think i should use something like SqlDataSource.UpdateCommand and SqlDataSource.UpdateParameters but dont know how to build from this a logic statement.

    Thanks in advance

    If you are using the SqlDataSource, in its Selected event, you can check the RowsAffected property. If it is > 0, set your bool to true:

    bool Check = False;

    protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
    int RecordCount = e.AffectedRows;

    if (RecordCount > 0)
    { Check = True; }
    }


    |||

    Actually I tried to make it in the Page_Load(object sender, EventArgs e) event. Does it change anything?

    I'm wondering if there is a way to get to sql query from C# code. Something like:

    [for each row from select query]

    bool present;

    if ( [row.taskID] == null )

    {

    present = false;

    }

    |||You will not get rows containing null from the query you showed in your example. You will only get rows that contain the TaskID that belong to the user specified. If there are no TaskIDs for that user, you will get no rows at all.|||

    I think i will get a row of some user even if he has NULL in taskID field. I checked this and i got the row that i wanted with empty value of the taskID field.

    But even if there would be e.g. -1 the problem still exists and i have no idea how to solve it or even where to look for solution.

    |||I beg your pardon. You are right. I didn't read your query correctly. You can access values from a datasource as described here:http://www.mikesdotnetting.com/Article.aspx?ArticleID=45, and check each value, setting your bool accordingly|||

    Thaks again, it works fine now. You are gosu ;)

    |||

    DCVer:

    You are gosu ;)

    Is that a good thing?Confused

    |||

    Yes, you are master, the king etcSmile

    logic error

    Declare @.mx int
    Set @.mx = (select max(score)
    from ,,,
    where ,,,,and
    substring(city,1,1)='g')
    select score,@.mx
    from ,,,,
    where ,,,, and
    substring(city,1,1)='g')
    group by score
    go
    this seems to work for small tables
    but when table is big and substring(city,1,1)='g')
    condition is not met it takes aweful time like goes
    in an infinit loop.
    --
    Sent by 3 from yahoo part of com
    This is a spam protected message. Please answer with reference header.
    Posted via http://www.usenet-replayer.comthat's because substring(city,1,1)='g') forces a table scan even if there is
    an index on city. the alternative is to use
    city like 'g%'
    --
    -oj
    RAC v2.2 & QALite!
    http://www.rac4sql.net
    "alexqa2003@.yahoo.com" <u128845214@.spawnkill.ip-mobilphone.net> wrote in
    message news:l.1065831439.1981964111@.[63.127.215.130]...
    > Declare @.mx int
    > Set @.mx = (select max(score)
    > from ,,,
    > where ,,,,and
    > substring(city,1,1)='g')
    > select score,@.mx
    > from ,,,,
    > where ,,,, and
    > substring(city,1,1)='g')
    > group by score
    > go
    > this seems to work for small tables
    > but when table is big and substring(city,1,1)='g')
    > condition is not met it takes aweful time like goes
    > in an infinit loop.
    >
    >
    > --
    > Sent by 3 from yahoo part of com
    > This is a spam protected message. Please answer with reference header.
    > Posted via http://www.usenet-replayer.com

    logic error

    Declare @.mx int
    Set @.mx = (select max(score)
    from ,,,
    where ,,,,and
    substring(city,1,1)='g')

    select score,@.mx
    from ,,,,
    where ,,,, and
    substring(city,1,1)='g')
    group by score
    go

    this seems to work for small tables
    but when table is big and substring(city,1,1)='g')
    condition is not met it takes aweful time like goes
    in an infinit loop.

    --
    Sent by 3 from yahoo part of com
    This is a spam protected message. Please answer with reference header.
    Posted via http://www.usenet-replayer.comthat's because substring(city,1,1)='g') forces a table scan even if there is
    an index on city. the alternative is to use

    city like 'g%'

    --
    -oj
    RAC v2.2 & QALite!
    http://www.rac4sql.net

    "alexqa2003@.yahoo.com" <u128845214@.spawnkill.ip-mobilphone.net> wrote in
    message news:l.1065831439.1981964111@.[63.127.215.130]...
    > Declare @.mx int
    > Set @.mx = (select max(score)
    > from ,,,
    > where ,,,,and
    > substring(city,1,1)='g')
    > select score,@.mx
    > from ,,,,
    > where ,,,, and
    > substring(city,1,1)='g')
    > group by score
    > go
    > this seems to work for small tables
    > but when table is big and substring(city,1,1)='g')
    > condition is not met it takes aweful time like goes
    > in an infinit loop.
    >
    >
    > --
    > Sent by 3 from yahoo part of com
    > This is a spam protected message. Please answer with reference header.
    > Posted via http://www.usenet-replayer.com

    Logging uses of SELECT ?

    Scenario:

    -I'm brand new to SQL Server 2000

    -I have a vendor supplied application running on SQLServer 2k.

    -I need to log which of my users has seen which data (from a
    particular table). It's a healthcare privacy thing.

    -The application does not do this and the vendor has no interest in
    implementing it, though it seems pretty easy if one has the app code.

    So I don't control the application or its code but I need to catch
    who's seen what. Note that I don't have to catch it all. In other
    words, I don't need to catch every instance, only whether user X has
    seen patient Y's data at all. So I'm talking about a fairly small data
    set. The end result I'm heading toward is a case in which a patient
    demands to know who's seen his health records. I go to a db table and
    say "select username from <viewlogtable> where patient_id = XXX".

    How do I do that? It'd be easy if I could it were possible to write a
    select trigger, or if I had some hooks into the app, but as it is I am
    stumped. This is trickier than logging updates and inserts...

    Thanks,
    JohnThere is no such thing as a SELECT trigger. You may be able to satisfy
    the requirement by analyzing the SQL log. There are some third party
    products that can be of use. Do a google on "Lumigent" for literature
    on their product.

    HTH

    =======================================
    Everyone here speaks SQL; some are more fluent, others less. When
    describing your SQL object (table, etc.), do so in the language that we
    all understand - SQL, not English. It makes it easier to understand
    your issue and makes it more likely that you will get the assistance
    that you are asking for.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!|||"John" <jgoodlea@.fhcrc.org> wrote in message
    news:80ff7fc9.0312151444.41c57adc@.posting.google.c om...
    > Scenario:
    > -I'm brand new to SQL Server 2000
    > -I have a vendor supplied application running on SQLServer 2k.
    > -I need to log which of my users has seen which data (from a
    > particular table). It's a healthcare privacy thing.
    > -The application does not do this and the vendor has no interest in
    > implementing it, though it seems pretty easy if one has the app code.
    > So I don't control the application or its code but I need to catch
    > who's seen what. Note that I don't have to catch it all. In other
    > words, I don't need to catch every instance, only whether user X has
    > seen patient Y's data at all. So I'm talking about a fairly small data
    > set. The end result I'm heading toward is a case in which a patient
    > demands to know who's seen his health records. I go to a db table and
    > say "select username from <viewlogtable> where patient_id = XXX".

    Unfortunately I can't see any way of doing that. There's no such thing as a
    select trigger.

    As another poster said, Lumigent may do this, but I doubt it since I don't
    believe Selects are logged at all. (wouldn't make much sense.)

    Another option is to run the SQL Profiler and setup a profile to look for
    JUST selects, etc. This solution actually might work fairly well
    short-term. And even long-term if you really tighten the profile down to
    record ONLY what you need.

    > How do I do that? It'd be easy if I could it were possible to write a
    > select trigger, or if I had some hooks into the app, but as it is I am
    > stumped. This is trickier than logging updates and inserts...

    Really what the vendor should be doing is all access through stored procs.
    Then the stored proc could handle security and handle logging.

    > Thanks,
    > John|||You would have to ensure that the users had to view that data by executing a
    stored procedure, not with a direct SELECT statement.
    I'm not sure how much control you have over the application, or if you can
    modify it, but this is certainly a way of 'logging' SELECT statements
    made against a table or set of tables. If you can, in fact, edit the
    application then you can edit it to execute a procedure that simply inserts
    into the log and selects as this <simplified>:

    DECLARE PROCEDURE ViewPatientRecords
    (
    @.PatientID int
    ,@.UserID int
    )
    AS

    INSERT INTO ViewLogTable(Patient_ID, Viewer_ID, View_Date)
    VALUES(@.Patient, @.UserID, GETDATE())

    SELECT *
    FROM Patient_Record
    WHERE Patient_ID = @.PatientID

    "John" <jgoodlea@.fhcrc.org> wrote in message
    news:80ff7fc9.0312151444.41c57adc@.posting.google.c om...
    > Scenario:
    > -I'm brand new to SQL Server 2000
    > -I have a vendor supplied application running on SQLServer 2k.
    > -I need to log which of my users has seen which data (from a
    > particular table). It's a healthcare privacy thing.
    > -The application does not do this and the vendor has no interest in
    > implementing it, though it seems pretty easy if one has the app code.
    > So I don't control the application or its code but I need to catch
    > who's seen what. Note that I don't have to catch it all. In other
    > words, I don't need to catch every instance, only whether user X has
    > seen patient Y's data at all. So I'm talking about a fairly small data
    > set. The end result I'm heading toward is a case in which a patient
    > demands to know who's seen his health records. I go to a db table and
    > say "select username from <viewlogtable> where patient_id = XXX".
    > How do I do that? It'd be easy if I could it were possible to write a
    > select trigger, or if I had some hooks into the app, but as it is I am
    > stumped. This is trickier than logging updates and inserts...
    > Thanks,
    > John