|
 |
sql_language thread: Getting value from dynamic statement
Message #1 by "Imar Spaanjaars" <Imar@S...> on Wed, 12 Sep 2001 19:20:38
|
|
Imar
Yes I agree having to go somewhat round the houses in
this way to change variables is messy.
Procs can of course call procs.
Sometimes you can get the boolean result you want by
creating as it where nested procs.
I actually like to return empty recordsets. The idea
is to reduce the types and levels of checks and who
does what the between client and server. SQL is not
Object orientated however DAO and ADO do have very
familiar class objects. I strive to keep SQL at the
server end and handle data through ADO - DAO type
objects.
If the client end is a distributed app then changes
(bugs correction) carry overheads in redistribution
(version checking etc).
If SQL can be confined to the server end and the
client is consistently looking for recordsets life
becomes so much easier.
Everybody instantly benefits from the revised Server
Code.
I hope everybody has got something out of this one.
--- Imar Spaanjaars <Imar@S...> wrote:
> Hi Roland,
>
> Looking good. I tested this a little and works OK.
>
> I'll test it in the real situation ASAP, to see if
> it works in my situation
> as well, but I have a good feeling about it.
>
> Seems to me that generating an (empty) resultset is
> far better than
> generating a cursor. Still pity that SQL can't
> change values of variables
> from within a SQL statement.
>
> Thanks for all your advice,
>
>
> Imar
>
>
>
> At 03:03 AM 9/14/2001 -0700, you wrote:
> >Hi Imar
> >
> >I am a Sussex man born an breed! (county in
> England).
> >I believe the family have links back to the 15th
> >Century.
> >
> >I am enjoying this one
> >
> >TRY this using sp_executesql
> >
> >create proc ImarTest
> >@id int
> >as
> >declare @sSqlStatement as nVarchar(2000)
> >select @sSqlStatement = 'SELECT
> >EventsActivitiesSql.dbo.TblProjects.ProjectNo
> >FROM EventsActivitiesSql.dbo.TblProjects
> >LEFT JOIN tblBulletins ON
> >EventsActivitiesSql.dbo.TblProjects.ProjectNo
> >tblBulletins.ProjectGroupid
> >WHERE (((tblBulletins.BulletinID) = @idBulletin))
> >'
> >declare @par nvarchar(50)
> >set @par = '@i... int'
> >
> >execute sp_executesql @sSqlStatement , @par,
> >@idBulletin = @id
> >
> >if @@Rowcount = 0
> > begin
> > print -1
> > end
> >else
> > begin
> > print 0
> > end
> >
> >I suspect this goes a long way to meeting your
> needs
|
|
 |