Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can not make query to work
Message
De
06/03/2003 16:29:24
Leo Kool
Agis Automatisering BV
Harmelen, Pays-Bas
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00762448
Message ID:
00762463
Vues:
10
Hi Nadya,

When you want to use the results of a previous select you can try this:
Select *
   Into #tmpTable
   From yourtable

Select *
   From #tmpTable

Drop Table #tmpTable
make sure to put the '#' before the tablename, indicating a temporary table.
drop the table for cleaning up.
>Hi everybody,
>
>Here is what I'm trying to do:
>declare @Sql varchar(1000), @tnCartID int, @Category char(1), @Temp char(1000)
>set @Temp = 'select CredID, State, Address from Credit..CreditInfo where CredID in ' +
>     '(select CredID from CartDetail inner Join CartContent on
>        CartDetail.CartContentID = CartContent.CartContentID and CartContent.CartID = 4' +
>      ' and CartContent.CreditCategory = '
>set @tnCartID = 4
>set @Category = 'L'
>
>SET @Sql = @Temp + quotename(@Category,char(34)) +')'
>
>execute (@Sql)
>
>Returns incorrect syntax near '='
>
>I can not make it work. I tried different combinations and the only working is
>
>SET @Sql =  'select CredID, State, Address from Credit..CreditInfo where CredID in ' +
>     '(select CredID from CartDetail inner Join CartContent on
>        CartDetail.CartContentID = CartContent.CartContentID and CartContent.CartID = 4' +
>      ' and CartContent.CreditCategory = ''' + @Category +''')'
>
>execute (@Sql)
>
>
>Also how can I reference result of select within procedure, e.g.
>select ...
>
>select .. from prev. select
>?
>
>Thanks in advance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform