[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Question about sql statement

Hello,

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?

Thanks

bibi
        
0
bibi92
Asked:
bibi92
1 Solution
 
Kalyanum Deepak KumarSenior Technical LeadCommented:
Hi bibi,

Cound not understand the question. Is that to place the parameters in a table and send them to the stored procedure.
0
 
Eugene ZCommented:
you need to clarify your question.

If I undestood you:

you need dynamic sql query

e.g

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 ''
0
 
Olaf DoschkeSoftware DeveloperCommented:
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 table.name = parameters.name

Bye, Olaf.
0
 
bibi92Author Commented:
Thanks bibi
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now