Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to create list from separate Sql
Message
 
À
05/02/2019 10:18:26
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2016
Divers
Thread ID:
01665900
Message ID:
01665928
Vues:
41
>Hi Borislav
>
>I see where we're going with this, and now, that section looks like
>
>  declare @TheOutputValue nvarchar(30) = ''
>  set @ThisSQL =  '(Select @TheOutputValue = CAST(' +  @ThisField  + ' as nvarchar(30)) from ' 
>      + @FileName + ' where ' + @KeyFieldName + ' = ' + cast(@KeyFieldValue as Varchar) + ')'
>  exec sp_executesql @ThisSQL, N'@ThisValue  nvarchar(30) OUTPUT', @ThisValue = @ThisValue 
>
>
>It keeps telling me I need to declare the scalar variable "@TheOutputValue", so (obviously) there's still something I'm missing


Sorry, my mistake.
I used @TheOutputValue but after that I decided to switch the name and forgot to use it in the query:
...
 set @ThisSQL =  '(Select @ThisValue = CAST(' +  @ThisField  + ' as nvarchar(30)) from ' 
      + @FileName + ' where ' + @KeyFieldName + ' = ' + cast(@KeyFieldValue as Varchar) + ')'
...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform