Popular Usenet Groups

Your one stop shop for all your most popular usenet groups in one place


Categories
Sports Science, Electronics & Maths Hobbies & Recreation
Religion TV & Media Computing - Programming
Music Cycling & Motorsports Computing - General
Photography Computing - Linux Computing - Apple Mac
Others Return to Home Page Register for extra features


Search This Site:

Go Back   Popular Usenet Groups > Computing - Progamming > microsoft.public.sqlserver.programming

microsoft.public.sqlserver.programming SQL Server Programming


 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 18th October 2007, 05:13 PM   #1
--CELKO--
 
Join Date: Oct 2007
Age: 14
Total Posts: 814
Re: using a variable in an In(Clause)

On Oct 18, 6:17 am, Paddy <paddymulla...@btopenworld.com> wrote:
> I have a value provided in the form of a string (varachar(max))
>
>> The value is of the type '1,2,3,4,5' <<


That is a VARCHAR(n) string and not a type of its own. SQL is a
compiled language, not interpreted like BASIC. It has one and only
one data structure -- the table. There are no vectors, arrays, lists,
etc.

>> It can be very long, but essentially it is list of comma separated values. <<


Define "very long"; if you mean 10,000 or so parameters, then this
ought to be put in a working table where you can scrub the data, use
an index, etc. If you mean 100 or fewer, then simply use a long
parameter list in a procedure call.

>> I want to use it in the where clause as part of the an 'IN' statement. <<


Newbies often want to do this, so there are a lot of kludges for it --
I know; I wrote one of the first of them years ago (single query with
a Sequence auxiliary table).

The problem is that the kludges do not handle the input list the same
way that the T-SQL compiler does. To do them right, you need to write
a parser in T-SQL and force the same error handling and messages. Or
you decide to either give up data integrity or to have two or more
different function behaviors in the system.

>> Dynamic SQL is not an option. <<


This is a good design decision. Dynamic SQL is a way of telling the
world that any future random user should be given control of the
system at run time. This is not usually a good thing


--CELKO-- is offline   Reply With Quote
 

Bookmarks


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Section Replies Last Post
Bug#461174: webcalendar: setting an environment variable does not set a $_ENV variable but a $_SERVER variable. ($_ENV variables are set for 'real' environment variables). As $_ENV['WEBCALENDER_CONFIG_FILE'] is used to check for a non-global config f B.Plagge Archive 0 17th January 2008 05:00 AM
Bug#461174: webcalendar: setting an environment variable does not set a $_ENV variable but a $_SERVER variable. ($_ENV variables are set for 'real' environment variables). As $_ENV['WEBCALENDER_CONFIG_FILE'] is used to check for a non-global config f B.Plagge Archive 0 17th January 2008 05:00 AM
Bug#461174: webcalendar: setting an environment variable does not set a $_ENV variable but a $_SERVER variable. ($_ENV variables are set for 'real' environment variables). As $_ENV['WEBCALENDER_CONFIG_FILE'] is used to check for a non-global config f B.Plagge Archive 0 17th January 2008 05:00 AM
Re: using a variable in an In(Clause) --CELKO-- microsoft.public.sqlserver.programming 16 19th October 2007 05:15 PM
Re: using a variable in an In(Clause) Tony Rogerson microsoft.public.sqlserver.programming 0 18th October 2007 06:50 PM


All times are GMT. The time now is 01:06 PM.


Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.