Questions tagged [sp-executesql]

sp_executesql is a system stored procedure in Microsoft's SQL Server product range (2005 onwards) for running dynamic SQL.

sp_executesql is a system stored procedure in Microsoft's SQL Server product range (2005 onwards).

It is used for running dynamic T-SQL Statements or batches, including support for embedded parameters.

It is also what the .NET framework uses for ad-hoc queries when parameters are added to a SqlCommand.

222 questions
0
votes
0 answers

PhoneGap - How to query SQLite in a for loop?

I have a problem with a SQLite query on PhoneGap application. I would open a folder and make a select with where clause for every entries in the folder. I open a for loop, after a select query, but the script uses same variables for all the entries…
ilPas
  • 21
  • 3
0
votes
2 answers

How to run a dynamic sql for each row of a table?

I have a table which contains a column named WhereClause DECLARE @UserGroups TABLE (WhereClause nvarchar(1000), totalCount int) The table has been populated with some values for WhereClause but none for totalCount column. An example of the…
The Light
  • 24,407
  • 61
  • 164
  • 254
0
votes
1 answer

T-SQL:exec() & sp_executedsql can't work with inserted & deteleted as input parameters

In my table there are three or more columns stored image file path, so I need to store the image file path to an specify table 'OnDeleteFile' when the data is going to delete,then the program to delete file in web server in task methord from this…
user1862341
  • 133
  • 1
  • 7
0
votes
2 answers

Create table in by sql statement using executeUpdate in Mysql

I have the following doGet(): protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MysqlDataSource ds = new MysqlConnectionPoolDataSource(); …
URL87
  • 9,430
  • 29
  • 98
  • 161
0
votes
3 answers

Set variables in stored procedure using EXECUTE sp_executesql

I'm trying to build an SQL string to execute via sp_executesql but I can't seem to assign value to a declared variable within the passed in sql string. So below is an example of my procedure ALTER PROCEDURE [dbo].[selectRecords] @psID INT…
Sun
  • 3,743
  • 12
  • 50
  • 91
-1
votes
1 answer

Why sometimes sp_executesql can be used in function sometimes not?

I have code in a SQL Server function: CREATE FUNCTION mpc.fun1 (@exp NVARCHAR(30))--@exp like '2*5/4' RETURNS DECIMAL(20, 10) AS BEGIN DECLARE @result decimal(13,4) DECLARE @str nvarchar(30)=N'SELECT @aOUT = 1.0 *' + @exp EXECUTE…
Alison Niu
  • 34
  • 3
-1
votes
3 answers

Why NVarchar(MAX) cannot execute complete dynamic query using SP_ExecuteSQL?

I created a stored procedure that will have two queries, those two queries will update records in two tables. So I will mention what it shows My procedure is like below ALTER PROC UpdateMissingItemONPoe @StoreID INT, @Name…
Liam neesan
  • 1,783
  • 4
  • 23
  • 49
-1
votes
2 answers

TSQL Evaluate expressions in table of concatenated strings

I have a table with constructed strings like below. Is there any way to execute each constructed string and store the result in another field within the row? ROW 1 'SELECT NAME FROM ZC_ETHNIC_GROUP WHERE INTERNAL_ID = 4' ROW 2 'SELECT NAME…
jch
  • 95
  • 2
  • 14
-1
votes
1 answer

syntax issue with sp_executesql

I'm trying to write a stored procedure and I keep getting this error that I haven't defined @address , which I did. I know I'm missing a little thing , how should I change this? CREATE PROCEDURE search_domaintable @link nvarchar(50), @address…
-1
votes
1 answer

How sp_executesql with select?

Please. I need to run a stored procedure that is stored in a temporary table. I have two tables: create table pruebaa ( cam1 integer primary key, cam2 varchar(20) ) insert into pruebaa (cam1, cam2) values (1, 'valor1'); insert into pruebaa…
-1
votes
3 answers

Like search in execute_sql not working properly

I'm facing a very strange behavior of a like search within a sp_executesql: This statement returns 0 rows: exec sp_executesql N'SELECT * FROM MyTable WHERE Name LIKE ''%'' + @Name + ''%''',N'@Name nvarchar(7)',@Name=N'100024​' When this…
user1416197
  • 135
  • 1
  • 7
-1
votes
2 answers

sp_executesql gives unclosed quotation mark error?

I've written simple stored procedure and executing using sp_executesql to tackle with quotation error and sql injection as well but when i pass a single quote in parameter still it shows me Unclosed quotation mark after the character string…
Vishwanath Dalvi
  • 31,604
  • 36
  • 115
  • 146
1 2 3
14
15