Sql Execute Query String

Posted By admin On 12/01/22
Active2 years, 10 months ago

Aug 07, 2017  EXECUTE (Transact-SQL); 25 minutes to read +3; In this article. APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse Executes a command string or character string within a Transact-SQL batch, or one of the following modules: system stored procedure, user-defined stored procedure, CLR stored procedure, scalar-valued user-defined.

I have a query string in variable

suppose Select Now();I want to execute it same like SQL do.I use

  • If at all possible look at avoiding the use of dynamic SQL especially where you start to manipulate the overall query string. I have a stored procedure using dynamic SQL to execute some commands at runtime, and use INSERT INTO statement to temporarily keep the.
  • After reading this article you will understand the basics of dynamic SQL; how to build statements based on variable values, and how to execute those constructed statements using spexecutesql and EXECUTE from within a stored procedure. All the examples for this lesson are based on Microsoft SQL.
  • Executes the specified pass-through query on the specified linked server. This server is an OLE DB data source. OPENQUERY can be referenced in the FROM clause of a query as if it were a table name. OPENQUERY can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement.

But It throws an exception

prepared statement 'SELECT now()' does not exist

and not allow me to execute it.


Is there any way to do that?


2 Answers

Vao TsunVao Tsun
30.1k6 gold badges41 silver badges68 bronze badges
Marlon Abeykoon

Mysql Execute Sql String

Marlon Abeykoon
6,4774 gold badges32 silver badges57 bronze badges

Not the answer you're looking for? Browse other questions tagged postgresqlpgadmin or ask your own question.