Re: How can a recordset returned by a sproc be updated?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jacco Schalkwijk (jacco.please.reply_at_to.newsgroups.mvps.org.invalid)
Date: 07/28/04


Date: Wed, 28 Jul 2004 13:52:24 +0100

You won't get a plain text update statement. ADO/ODBC will use sp_prepare
and a few other extended procedures to execute the statements it builds on
the basis of the metadata that is send along with the resultset from the
stored procedure.

-- 
Jacco Schalkwijk
SQL Server MVP
"Uri Dimant" <urid@iscar.co.il> wrote in message 
news:OQep44JdEHA.2504@TK2MSFTNGP12.phx.gbl...
> Jacco
> While I run the test on my box I haven't seen update statement as OP said. 
> I
> did exactly the same thing as he is described.
>
> "Jacco Schalkwijk" <jacco.please.reply@to.newsgroups.mvps.org.invalid> 
> wrote
> in message news:OPVZy1JdEHA.4092@TK2MSFTNGP10.phx.gbl...
>> Hi Richard,
>>
>> With the resultset metadata is returned to the client that allows ADO and
>> ODBC etc to create update , insert delete statements etc against the base
>> tables. This works for both stored procedures and views. For views you 
>> can
>> prevent this metadata being sent by creating the view with the WITH
>> VIEW_METADATA option. This will return metadata for the view instead of
> the
>> underlying tables.
>>
>> You can revoke or deny permissions on the base tables as well if you want
> to
>> prevent updates.
>>
>> -- 
>> Jacco Schalkwijk
>> SQL Server MVP
>>
>>
>> "Richard Hayward" <richard@tortoise.demon.co.uk> wrote in message
>> news:jj9gg01lvosqnu6kp0ok7m8oiogufj5rud@4ax.com...
>> >I have an application written in Delphi connecting to MSSQL 2000 via
>> > ADO.
>> >
>> > At the server, using the example pubs database I've created a stored
>> > procedure:
>> >
>> > CREATE  PROCEDURE spAuthor  AS
>> > select * from authors
>> >
>> > My application displays the resulting records in a grid.
>> > To my surprise, the application is also able, via ADO,  to update the
>> > table in pubs.
>> >
>> > Watching whats going on with SQL profiler,  somehow SQL gets
>> > generated, to update the correct table on the
>> > server. How can that be possible? I gave the application no knowledge
>> > of which table my data was coming from. Can ADO somehow get at the
>> > internal text of the stored procedure? Or does the returned recordset
>> > carry with it the names of the tables its fields came from?
>> >
>> > Next, I tried making a view and having the stored procedure select
>> > from the view instead:
>> >
>> > CREATE VIEW vAuthors
>> > AS
>> > select *
>> > from authors
>> >
>> > CREATE  PROCEDURE spAuthor  AS
>> > select * from vAuthors
>> >
>> >
>> > but still, SQL is somehow generated to update the underlying table.
>> >
>> >
>> > Could anyone enlighten me as to how this is possible?
>> >
>> > regards
>> > Richard
>> >
>> >
>> > richard@tortoise.demon.co.uk
>>
>>
>
> 


Relevant Pages

  • Re: Returns a names of columns from a query in stored procedure
    ... through ADO, there is .Name property for each ordinal column returned in ... Mike Epprecht, Microsoft SQL Server MVP ... How I can return the name of columns from a query that was carried through ... With stored procedure "sp_columns" I can return the columns of a table, ...
    (microsoft.public.sqlserver.programming)
  • Re: using transact sql in msaccess forms
    ... ADO to execute a stored procedure containing the update statement, ... ADO, and some other things. ...
    (microsoft.public.sqlserver.server)
  • Re: Cannot update identity column PointOfSaleID.
    ... The sp_MSupd_PointOfSales stored procedure checks to see if the bit flag ... set and if so it executes an update statement which includes the identity ... for the identity column, it executes fine and chooses the else path. ...
    (microsoft.public.sqlserver.replication)
  • A few T-SQL questions...
    ... I have a few T-SQL questions that i'm hoping someone can answer for me. ... trips (i'm not using a stored procedure for this for several reasons). ... What's the best way to write an update statement so that only fields ... I have a table that has a trigger that does ...
    (microsoft.public.sqlserver)
  • Re: Help on resolving record conflicts with ADO
    ... When ADO Posts, it constructs an SQL update statement. ... that only use the PrimaryKey as in "Where" clause. ...
    (borland.public.delphi.database.ado)