Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: sp and conditional temp table
Message
De
23/05/2005 06:11:46
 
 
À
23/05/2005 05:52:18
Jon Neale
Bond International Software
Wootton Bassett, Royaume Uni
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01016662
Message ID:
01016670
Vues:
11
>I'm not sure what your doing so this may not be what your looking for.
>
>But how about:
>
>CREATE PROCEDURE dbo.test1
> @choice bit = 0
>as
> exec('select CAST( ' + @choice + ' as varchar(1)) X from #temptable')
>
>You have vastly more experience than me so excuse the answer if its not what your after.
>
>Jon
>
hi Jon

of course, a workaround with
exec "dynamic script"
or PUTTING conditions into a single SELECT
CREATE	PROCEDURE dbo.test1
	@choice bit = 0
as
	SELECT CASE WHEN @choice=0 THEN 1 ELSE 0 END x INTO #TEMPTABLE
is possible;
but:
* Exec 'SELECT ....'
- is unreadable
- is uncacheable

* conditional select
- can become unreadable
- it can easy confuse the MS SQL optimizer
and create of the inefficient plans

MS SQL it is a good product,
but in some points the team has been overwhelmed from the complexity
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform