dynamic-sql Questions

4

Solved

I Have created a procedure which has code like this: Create PROCEDURE Sample( @ID INT ) AS BEGIN DECLARE @SQL NVARCHAR(max) DECLARE @SchemaName SYSNAME DECLARE @TableName SYSNAME DECLARE @D...
Dagall asked 23/3, 2011 at 19:44

1

Solved

I'm trying to get this dynamic SQL running ( using EXECUTE IMMEDIATE) M_SQL_STATEMENT := 'SELECT MAX(:m_var1)+1 from :m_var2 RETURNING MAX(:m_var1)+1 INTO :m_var3'; EXECUTE IMMEDIATE M_SQL_STATEM...
Standoff asked 10/3, 2011 at 12:39

1

Solved

A Dynamic SQL query from lobodava is: declare @sql nvarchar(4000) = N';with cteColumnts (ORDINAL_POSITION, COLUMN_NAME) as ( select ORDINAL_POSITION, COLUMN_NAME from INFORMATION_SCHEMA.COLUM...
Unpromising asked 10/3, 2011 at 4:29

2

Solved

I have been researching this for a couple of days and feel like I am going around in circles. I have basic knowledge of SQL but there are many areas I do not understand. I have a table that stores...
Indeterminable asked 6/3, 2011 at 11:25

1

Solved

I have a stored procedure which used the EXECUTE IMMEDIATE command to execute a very long string. How do I support a very long string and return the data into a refcursor?
Frecklefaced asked 17/1, 2011 at 14:17

2

Solved

Below mentioned stored procedure is giving error while creating Msg 156, Level 15, State 1, Procedure crosstab, Line 23 Incorrect syntax near the keyword 'pivot'. Can anyone please tell me the m...
Chenopod asked 29/9, 2010 at 13:6

2

I have a database where all access is controlled by stored procedures. The DBA would like to avoid giving users direct read/write access to the underlying tables, which I can understand. Hence all ...
Disturbing asked 28/9, 2010 at 19:54

3

Solved

I want to accomplish this: update @sourceDatabase.dbo.PredictedPrices and then set @sourceDatabase as a variable. But I'm not allowed? Incorrect syntax near '.'. Is there another way?
Sheepfold asked 28/9, 2010 at 9:5

2

Solved

My co-worker is being unsafe with his code and is allowing a user to upload an SQL file to be run on the server. He strips out any key words in the file such as "EXEC", "DROP", "UPDATE", "INSERT", ...
Forever asked 16/9, 2010 at 22:7

1

Solved

Need help with this SQL Server 2000 procedure. The problem is made difficult because I'm testing procedure via Oracle SQL Developer. I'm running the procedure to iterate column with new sequence o...

3

Solved

I have a requirement in which in order to make an application extensible and reusable, I have to create a provision through which a user would be able to provide a business object structure (the fi...
Panta asked 17/8, 2010 at 14:29

2

Solved

I remember back in the day I would make a whole wack of nvarchar(4000) vars, check the length of them as they grew, switch them out as they filled up and then concatenate the whole mess together fo...
Pre asked 6/7, 2010 at 21:36

2

Solved

I'm currently using sp_executesql to execute a T-SQL statement with a dynamic table name. However, it is really ugly to see something like: set @sql = 'UPDATE '+Table_Name+' SET ... WHERE '+someV...
Septuple asked 18/6, 2010 at 10:18

7

Solved

Here's a tricky one - how do I programatically create and interrogate a database whose contents I can't really foresee? I am implementing a generic input form system. The user can create PHP forms...
Plemmons asked 10/6, 2010 at 2:19

5

Solved

Consider the following TSQL: SET @WhereClause1 = 'where a.Date > ' + @InvoiceDate I get a date/string conversion error. @InvoiceDate is a datetime variable. What is the right syntax?
Pulley asked 2/4, 2009 at 5:2

2

Solved

I'm just starting to learn T-SQL and could use some help in understanding what's going on in a particular block of code. I modified some code in an answer I received in a previous question, and her...
Carolinecarolingian asked 31/3, 2010 at 18:42

3

Solved

What is a dynamic SQL query, and when would I want to use one? I'm using SQL Server 2005.
Blackmun asked 3/2, 2010 at 6:3

3

Solved

I don't understand why the following is giving me the error. I thought it was related to the commented out section, but @SQL is nvarchar(4000). BEGIN sp_executesql N'SELECT ''td''' --sp_executes...
Brigette asked 18/8, 2009 at 22:54

6

Solved

I am storing and editing some field in a database that involves a long string of one or more sentences. whenever i enter a single quote in the textbox and want to save it it throws an exception lik...
Cardinal asked 14/7, 2009 at 11:10

5

I currently have a 'Filter' object which corresponds to a business object. This object has properties that relate to the different ways that I want to be able to filter/search a list of such busine...
Headroom asked 18/6, 2009 at 13:52

6

Solved

I want to run a query like this: SELECT * FROM Studio WHERE Id IN (134, 144, 132, 138, 7432, 7543, 2566) but the amount of Id's passed to the IN clause is only determined at runtime. Do I have...
Rozier asked 10/6, 2009 at 17:24

3

Solved

Is there a way to select a database from a variable? Declare @bob as varchar(50); Set @bob = 'SweetDB'; GO USE @bob
Kurdish asked 1/6, 2009 at 23:16

1

Solved

I am writing a PL/SQL procedure that needs to to dynamically generate some queries, one of which involves creating a temporary table using results from a query taken as a parameter. CREATE OR REPL...
Probation asked 19/5, 2009 at 22:17

3

I'd need to know how to parse a query to know if it is well build before executing it. If the parsing is correct then execute it, if not discard it. I haven't been able to accomplish this using SE...
Granlund asked 7/5, 2009 at 10:55

3

I'm looking for a pattern for performing a dynamic search on multiple tables. I have no control over the legacy (and poorly designed) database table structure. Consider a scenario similar to a re...

© 2022 - 2024 — McMap. All rights reserved.