October 9, 2007 at 5:54 am
hi all,
i want to write a generic Insert & update procedure.It should work with different tables having different datatypes.suppose let say table1 may have col1 int,col2 varchar... and let say table2 may have col1 varchar,col2 char..like that..and so on..
generally till now wat iam doing is that iam writting different stored procedure for different tables..
Now i want to write One Insert & update procedure in my project...and for all the tables in the project i want to use only that procedure.
Is it Possible? If yes kindly help me ..on resolving this issue..
Thanks & regards
suman
October 9, 2007 at 6:18 am
aarrgghhh!
[font="Comic Sans MS"]The GrumpyOldDBA[/font]
www.grumpyolddba.co.uk
http://sqlblogcasts.com/blogs/grumpyolddba/
October 9, 2007 at 7:38 am
Please don't cross-post the same question.
http://www.sqlservercentral.com/Forums/Topic408403-338-1.aspx
And I agree with the initial response.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 9, 2007 at 4:57 pm
And just how do you plan on passing the data to insert or update?
October 10, 2007 at 5:48 am
Hi,
for creating a stored procedure for different tables you should do following:
create proc usp_name
(
@parameter1 bigint = null ,
@parameter2 bigint = null ,
@parameter3 bigint = null ,
@parameter4 bigint = null
)
if @parameter1 = 1
Begin
Insert into table1 -->this is an example
End
if @parameter1 = 2
Begin
update table1 -->this is an example
End
if @parameter1 = 3
Begin
delete table1 -->this is an example
End
using this you can do desired functionality.
you can give any no of parameters values.
October 19, 2007 at 4:49 am
DONT DO THIS....
"Keep Trying"
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply