Results 1 to 5 of 5

Thread: Modifying the database SP in Patch

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    102

    Modifying the database SP in Patch

    Hello Friends

    1) How do i write code/script to modify the Stored procedure once the database is up and running in client place.

    2 )I want to write a patch so that the user double clicks it and the changes happen.

    3) I know how to modify the database fields using SQL queries.... but how do i include this in the script ?

    4 ) Can i do this is ASP.NET ?

    Please Help
    Sara

  2. #2
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: Modifying the database SP in Patch

    Quote Originally Posted by sara_23apr
    Hello Friends

    1) How do i write code/script to modify the Stored procedure once the database is up and running in client place.

    2 )I want to write a patch so that the user double clicks it and the changes happen.

    3) I know how to modify the database fields using SQL queries.... but how do i include this in the script ?

    4 ) Can i do this is ASP.NET ?

    Please Help
    Sara
    1. Use the ALTER statement. You can generate ALTER scripts with SQL Server Management Studio. Just right-click a stored procedure and select Script As->Alter To->New Query Window.

    2. You can create a program that the user can use to open and execute sql scripts, or you can simply teach him/her to use SQL Server Management Studio to execute the sql scripts.

    3. You can include any kind of SQL statements in a script. UPDATE, INSERT, DELETE, CREATE, ALTER etc. The only thing you must keep in mind is that some statements, like CREATE and ALTER, cannot be combined with other statements in one batch. You must therefore separate each CREATE/ALTER script in a script file with the word GO

    4. Sure it can. You can create a web page that allows you to upload a sql-script file and have the server execute it.

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Modifying the database SP in Patch

    We script all our SPROC creation - something that looks like this (and it's stored in a TEXT file ending with a .SQL extension).

    sql Code:
    1. Use Funds
    2.  
    3. SET QUOTED_IDENTIFIER ON
    4. GO
    5. SET ANSI_NULLS ON
    6. GO
    7.  
    8. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetImageInfo_P]')
    9.     and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    10. drop procedure [dbo].[GetImageInfo_P]
    11. GO
    12.  
    13. Create Procedure GetImageInfo_P
    14. as
    15.  
    16. Select ConfItem,ConfData From Funds_T Where Left(ConfItem,5)='Image'
    17.  
    18. GO
    19. GRANT EXEC ON GetImageInfo_P to FundsUser
    20. GO
    21. SET QUOTED_IDENTIFIER OFF
    22. GO
    23. SET ANSI_NULLS ON
    24. GO
    These .SQL files can be executed many ways - one way is to run them manually in a QUERY window (Query Analyzer or Management Studio).

    Also - there is a command line OSQL command that will load the SPROC into the database - you can place these commands in a .BAT file and the user can execute that file:

    osql /E /S SERVER03 /i GetImageInfo_P.sql /o log_GetImageInfo_P.sql.txt

    You can also run a statement like this from within your APP - after finding all the .SQL files that need to be re-loaded in a staging folder, for instance.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    102

    Re: Modifying the database SP in Patch

    Hi kaffenils and szlamany

    Thanks for the reply

    I am off the work today... will try this tommarrow and get back

    Regards
    Sara

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    102

    Re: Modifying the database SP in Patch

    Hi szlamany and kaffenils
    Your replies were very helpful and informative.

    I have created the .Sql file and now working on executing the .sql file from asp.net using ExecuteNonQuery()

    Thank you

    Sara

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width