• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2331
  • Last Modified:

SET @VALUE = EXEC(@QUERY) ?????

Hi,
I try to do this  (title).
what is the good syntax ?
Thanks.
0
bruno_boccara
Asked:
bruno_boccara
2 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
EXEC doesn't return values and it's only for run Stored Procedures.
If @Query contains a SP name then you can use it like this:
EXEC @VALUE = @QUERY

If it's really a SQL Statement then you should use:
sp_executesql @QUERY

But this only returns 0 (sucess) or 1 (failure)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now