Generic Insert & update procedure in SQLSERVER2000

  • 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

  • aarrgghhh!

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • Please don't cross-post the same question.

    http://qa.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 RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • And just how do you plan on passing the data to insert or update?

  • 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.

  • 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