Top "Sp-executesql" questions

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

Execute very long statements in TSQL using sp_executesql

I would like to execute dynamic SQL statements which are about 10,000 characters. When I use sp_executesql as below: DECLARE @…

sql-server sql-server-2008 tsql sp-executesql
Passing user defined table parameter to dynamic sql, sp_executesql

I need help with passing my "user defined table type" parameter to dynamic sql, sp_executesql. Here's my sample code: …

sql parameters sp-executesql
Dynamic Column Name in SQL in Update statement

DECLARE @sql NVARCHAR(max) DECLARE @ParmDefinition NVARCHAR(500) SET @sql = 'UPDATE [Table1] SET [Table1].[@columnName] = TEST'; SET @ParmDefinition = N'@columnName NVARCHAR(50)…

sql-server sp-executesql
sp_executesql or exec(@var) is too long. Maximum length is 8000

I have large queries so i cant use linked server in production by rules. i pass a varchar(max) which …

sql-server-2005 varchar sp-executesql large-data
Easy way to convert exec sp_executesql to a normal query?

When dealing with debugging queries using Profiler and SSMS, its pretty common for me to copy a query from Profiler …

sql-server macros format ssms sp-executesql
INSERT INTO temporary table from sp_executsql

Generally, I am bulding dynamic SQL statement that is executing using sp_executsql like this: EXEC sp_executesql @TempSQLStatement I …

tsql temp-tables sp-executesql global-temp-tables
Using LIKE in sp_executesql

SET @whereCond = @whereCond + ' AND name LIKE ''%'' + @name + ''%''' Is there something wrong here? After I generate …

sql-server sql-server-2008 sp-executesql
How to pass a table variable using sp_executesql

I'm trying to create a table using sp_executesql but I keep getting an error that says "Incorrect syntax near …

sql sql-server dynamic-sql sp-executesql
How do I truncate a table via linked server using a synonym for the table name?

I know I can do the following: EXEC Server_Name.DBName.sys.sp_executesql N'TRUNCATE TABLE dbo.table_name' But …

sql-server tsql linked-server synonym sp-executesql