Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1085

How to Get Local Variables That Are Not So Local

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject How to Get Local Variables That Are Not So Local
Date 2012-05-29 19:55 -0700
Organization A noiseless patient Spider
Message-ID <et1bs791hjssp3ppig64cnn1ufg2qgciu7@4ax.com> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Dear SQLers:

     I have written a longish script.  I am up to just over 800 lines,
and there is way more to come yet.  In it, I define a number of stored
procedures.  I have test code for most of them.  My script looks
something like:
          setup database
          create tables and indexes
          repeat n times
             create procedure
             test procedure
          check table results
          end off

     I would like the option of easily turning off the testing.

  1) I wish I could define a variable at the start of the script and
check that with each of my tests.  Unfortunately, the scope of a local
variable is but the batch it is defined in.  Or is there a way of
defining a longer-lived variable?

  2) An alternative would be to create a table and insert a row to
indicate whether to test.  That would be a kludge.

     T-SQL does seem to be missing some of the oddest things.  Is this
another case of that, or is it that I just do not know about nonlocal
variable declarations?

Sincerely,

Gene Wirchenko

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

How to Get Local Variables That Are Not So Local Gene Wirchenko <genew@ocis.net> - 2012-05-29 19:55 -0700
  Re: How to Get Local Variables That Are Not So Local Erland Sommarskog <esquel@sommarskog.se> - 2012-05-30 07:20 +0000
    Re: How to Get Local Variables That Are Not So Local Gene Wirchenko <genew@ocis.net> - 2012-05-30 09:56 -0700
      Re: How to Get Local Variables That Are Not So Local Erland Sommarskog <esquel@sommarskog.se> - 2012-05-30 20:50 +0200
        Re: How to Get Local Variables That Are Not So Local Gene Wirchenko <genew@ocis.net> - 2012-05-30 13:31 -0700
          Re: How to Get Local Variables That Are Not So Local Erland Sommarskog <esquel@sommarskog.se> - 2012-05-31 07:23 +0000
  Re: How to Get Local Variables That Are Not So Local rja.carnegie@gmail.com - 2012-06-14 04:20 -0700
    Re: How to Get Local Variables That Are Not So Local Erland Sommarskog <esquel@sommarskog.se> - 2012-06-14 21:43 +0200
      Re: How to Get Local Variables That Are Not So Local Gene Wirchenko <genew@ocis.net> - 2012-06-14 14:58 -0700

csiph-web