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


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

Re: How to Get Local Variables That Are Not So Local

Path csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Re: How to Get Local Variables That Are Not So Local
Followup-To comp.databases.ms-sqlserver
Date Wed, 30 May 2012 07:20:08 +0000 (UTC)
Organization Erland Sommarskog
Lines 45
Message-ID <XnsA0635EF73D48FYazorman@127.0.0.1> (permalink)
References <et1bs791hjssp3ppig64cnn1ufg2qgciu7@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Date Wed, 30 May 2012 07:20:08 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="G7+Jz22XqYCG8C6rb1H3YA"; logging-data="23907"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ROyLuEWpEVkyilTo70/4h"
User-Agent Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32)
Cancel-Lock sha1:zfoWCCZcvNpu7GRCoXhbcr1qNRM=
Xref csiph.com comp.databases.ms-sqlserver:1086

Cross-posted to 2 groups.

Followups directed to: comp.databases.ms-sqlserver

Show key headers only | View raw


Gene Wirchenko (genew@ocis.net) writes:
>      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?
 
T-SQL is a language to query and modify relational database. For this it is 
a very powerful language.

However, T-SQL is not a general-purpose language, and if you try to use it 
for something it is not intended, you will have to accept the raw edges.

If you want a smoother ride, move the administrative tasks to the client-
side language of your choice.



-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next 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