Question about sql statement

Posted on 2011-04-23
Last Modified: 2012-08-13

In a script, I have this statement for update stored procedures :
UPDATE sql_sp
      SET    SQL = REPLACE(SQL,  '@c6
      ,@c7' ,  '@c6
      ,@c7, '''+@schemasource+'''' )
      where name = 'sp_MSins_'+@schemasource+'ACCOS'

How can I put it in a table parameters?


Question by:bibi92
    LVL 4

    Expert Comment

    by:Kalyanum Deepak Kumar
    Hi bibi,

    Cound not understand the question. Is that to place the parameters in a table and send them to the stored procedure.
    LVL 42

    Accepted Solution

    you need to clarify your question.

    If I undestood you:

    you need dynamic sql query


    declare @sql varchar(max)
    set @sql='UPDATE ' +@sql_sp +
         ' SET    SQL = REPLACE(SQL,  ' +@c6+
         ' , +@c7+' ,  '+@c6+'
          ,'+@c7 +',''' +@schemasource+''' )
          where name = ''sp_MSins_'''+@schemasource+'''ACCOS''

    something like this - just need to adjust ''
    LVL 29

    Expert Comment

    by:Olaf Doschke
    How can I put it in a table parameters?

    "it": What?

    "a parameters" : parameters is plural, that grammar makes no sense at all.

    Did you mean: "How can I put parameters into a table?"

    Well, that's not really the problem, is it? You can put values into a table. The question is how to use table records to replace parameters, and that's simply by joining the table with parameters and replacing parameters with the tablename.fieldname syntax.

    In a simpler example:

    Select * from table where name = @name

    create a table named parameters with a field name, then you can instead do:

    Select table.* from table inner join parameters on =

    Bye, Olaf.

    Author Closing Comment

    Thanks bibi

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now