Click here to Skip to main content
15,914,924 members
Home / Discussions / Database
   

Database

 
GeneralRe: MySQL GRANT SELECT Pin
Colin Angus Mackay31-Dec-04 15:46
Colin Angus Mackay31-Dec-04 15:46 
GeneralTOPLESS LADIES INSIDE - SQL Pin
HarryBo30-Dec-04 9:10
HarryBo30-Dec-04 9:10 
GeneralRe: TOPLESS LADIES INSIDE - SQL Pin
Javier Lozano1-Jan-05 13:44
Javier Lozano1-Jan-05 13:44 
GeneralOracle forms 6i problem Pin
missnazar30-Dec-04 4:00
missnazar30-Dec-04 4:00 
GeneralStored Procedure PRoblem Pin
percyvimal30-Dec-04 2:15
percyvimal30-Dec-04 2:15 
GeneralRe: Stored Procedure PRoblem Pin
Mike Dimmick30-Dec-04 3:50
Mike Dimmick30-Dec-04 3:50 
I'd recommend splitting this into two procedures, add and edit. The query processor will either have to build one query plan with redundant code, or, more likely, recompile the query plan every time you swap the value of @AddMode.

As for your specific problem, you can only parameterize values. You can't parameterize schema. If you have to, you've probably designed your database incorrectly. Tables are not objects. Creating and dropping tables are very expensive operations.

If you absolutely must do this, you should use string concatenation to form the schema part of the query, then use sp_executesql to execute it supplying the parameters, e.g.:
DECLARE @query varchar(2000)
SET @query = 'UPDATE ' + @GenTable + 
             ' SET ' + @GenNameField + ' = @GenName WHERE ' + 
             @GenCodeField + ' = @GenCode'

EXEC sp_executesql @query, 
      N'@GenName varchar(100), @GenCode int',
      @GenName, @GenCode


Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:29
abbaskaya30-Dec-04 4:29 
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:30
abbaskaya30-Dec-04 4:30 
GeneralRe: Stored Procedure PRoblem Pin
percyvimal30-Dec-04 5:44
percyvimal30-Dec-04 5:44 
GeneralRe: Stored Procedure PRoblem Pin
WoutL30-Dec-04 9:33
WoutL30-Dec-04 9:33 
GeneralRe: Stored Procedure PRoblem Pin
percyvimal30-Dec-04 10:42
percyvimal30-Dec-04 10:42 
GeneralRe: Stored Procedure PRoblem Pin
WoutL31-Dec-04 0:43
WoutL31-Dec-04 0:43 
GeneralUnable to install Oracle 8i Release 3 Pin
missnazar30-Dec-04 0:02
missnazar30-Dec-04 0:02 
GeneralRe: Unable to install Oracle 8i Release 3 Pin
Graham Bradshaw30-Dec-04 0:18
Graham Bradshaw30-Dec-04 0:18 
GeneralRe: Unable to install Oracle 8i Release 3 Pin
missnazar30-Dec-04 3:46
missnazar30-Dec-04 3:46 
GeneralWhy Reset button does not work more than once in ASP.NET web application Pin
amittinku29-Dec-04 23:03
amittinku29-Dec-04 23:03 
GeneralRe: Why Reset button does not work more than once in ASP.NET web application Pin
Colin Angus Mackay1-Jan-05 3:07
Colin Angus Mackay1-Jan-05 3:07 
QuestionWhy ASP.NET webapplications/webservies are not running/working on my system? Pin
amittinku29-Dec-04 20:10
amittinku29-Dec-04 20:10 
GeneralInconsistent, but there should be an explanation Pin
mysorian29-Dec-04 11:11
professionalmysorian29-Dec-04 11:11 
GeneralRe: Inconsistent, but there should be an explanation Pin
Rob Graham30-Dec-04 14:14
Rob Graham30-Dec-04 14:14 
GeneralRe: Inconsistent, but there should be an explanation Pin
mysorian30-Dec-04 18:32
professionalmysorian30-Dec-04 18:32 
GeneralCase-Sensitive Pin
Ahmed Galal29-Dec-04 0:13
Ahmed Galal29-Dec-04 0:13 
GeneralRe: Case-Sensitive Pin
Colin Angus Mackay29-Dec-04 1:40
Colin Angus Mackay29-Dec-04 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.