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

Database

 
GeneralRe: Database connection problem Pin
RichC4-Apr-04 14:35
RichC4-Apr-04 14:35 
GeneralHierarchical structure in ADO.Net Pin
P I2-Apr-04 4:07
P I2-Apr-04 4:07 
GeneralRe: Hierarchical structure in ADO.Net Pin
John Kuhn2-Apr-04 15:55
John Kuhn2-Apr-04 15:55 
GeneralDate format Pin
Xander802-Apr-04 3:50
Xander802-Apr-04 3:50 
GeneralRe: Date format Pin
Mike Dimmick2-Apr-04 5:34
Mike Dimmick2-Apr-04 5:34 
GeneralLimiting a text field Pin
monrobot131-Apr-04 9:10
monrobot131-Apr-04 9:10 
GeneralStored Proc Newbie Pin
quilkin1-Apr-04 6:26
quilkin1-Apr-04 6:26 
GeneralRe: Stored Proc Newbie Pin
Colin Angus Mackay1-Apr-04 6:58
Colin Angus Mackay1-Apr-04 6:58 
chris fearnley wrote:
INSERT @whichtable (n,nme) VALUES (@num,@name)

I don't think you can substiture a variable for a table name - it messes with SQL Server's ability to pre-compile stored procedures then use the compiled version.

What you need to do is create something like:
IF @whichtable = 'TableA'
    INSERT TableA (n,nme) VALUES (@num,@name)
ELSE IF @whichtable = 'TableB'
    INSERT TableB (n,nme) VALUES (@num,@name)
ELSE IF @whichtable = 'TableC'
    INSERT TableC (n,nme) VALUES (@num,@name)


There is another method whereby you can create a string containing the relevant SQL and get it to parse and execute the string, but I don't recall off the top of my head how to do that. Also, if performance is important you don't want stored procedures parsing SQL midflight.

Does this help?


"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar

"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)


GeneralRe: Stored Proc Newbie Pin
quilkin1-Apr-04 10:16
quilkin1-Apr-04 10:16 
GeneralRe: Stored Proc Newbie Pin
Colin Angus Mackay1-Apr-04 10:30
Colin Angus Mackay1-Apr-04 10:30 
GeneralRe: Stored Proc Newbie Pin
quilkin2-Apr-04 11:12
quilkin2-Apr-04 11:12 
GeneralRe: Stored Proc Newbie Pin
Colin Angus Mackay2-Apr-04 12:03
Colin Angus Mackay2-Apr-04 12:03 
GeneralRe: Stored Proc Newbie Pin
Jeff Martin1-Apr-04 10:32
Jeff Martin1-Apr-04 10:32 
GeneralMerging Views in ADO.NET Pin
Gary Hyslop1-Apr-04 4:32
Gary Hyslop1-Apr-04 4:32 
GeneralRe: Merging Views in ADO.NET Pin
-Dr_X-1-Apr-04 16:24
-Dr_X-1-Apr-04 16:24 
GeneralRe: Merging Views in ADO.NET Pin
Gary Hyslop2-Apr-04 8:54
Gary Hyslop2-Apr-04 8:54 
Generala query suing Time format Pin
Brutaldeath01-Apr-04 3:19
sussBrutaldeath01-Apr-04 3:19 
GeneralRe: a query suing Time format Pin
Colin Angus Mackay1-Apr-04 3:30
Colin Angus Mackay1-Apr-04 3:30 
GeneralRe: a query suing Time format Pin
Colin Angus Mackay1-Apr-04 3:35
Colin Angus Mackay1-Apr-04 3:35 
GeneralRe: a query suing Time format Pin
peterzorbas3-Apr-04 12:10
peterzorbas3-Apr-04 12:10 
GeneralMS Access Transactions Pin
opopov31-Mar-04 6:54
opopov31-Mar-04 6:54 
GeneralRe: MS Access Transactions Pin
Xiangyang Liu 刘向阳31-Mar-04 7:53
Xiangyang Liu 刘向阳31-Mar-04 7:53 
GeneralRe: MS Access Transactions Pin
opopov31-Mar-04 8:37
opopov31-Mar-04 8:37 
QuestionDataSets with Serialization? Pin
docdeath31-Mar-04 6:33
docdeath31-Mar-04 6:33 
GeneralSQL Server and MSDE Pin
Prasad N31-Mar-04 2:00
Prasad N31-Mar-04 2:00 

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.