Hi, We have an application using databases with hard coded references referring other databases( in the same instances). Now if we need to add a new client we have to install a new instance and use the same database names for the new customer, because we can't just change the names of the databases as they are all over the code -hard coded. Now is there any possible way to replace the hard coded references and change the database names when ever we want to add a new customer in the same instance.
When you say hard-coded you mean that there are database objects that have references to other databases or that the application refers to more than one database? If its the application then there will only be an option to alter this in the code and recompile it. If its in the database objects (views, stored procs, etc) then it may be possible to find all mentions of the other database and alter/remove them. It will be a case of trial and error in the later stages of the work but there are some tools that you could use to help you. RedGate have a free tool called SQL Search that will seek out any phrase within a database but to my knowledge it doesnt do a search and replace.
Hi If you're refering to code included in the database objects, you can script all the stored procedures, views, functions, triggers, constraints, anything that may contain a piece of TSQL and do a search - and - replace in the file you get. I would be also looking for any piece of code contained in DTS/DTSX packages that may reference objects in a hardcoded manner. If there are any ad-hoc queries that are ran against that database on a relatively regular basis, those should be checked as well. if you store any connection strings inside the databse for whatever reason (dynamic connections to the database, etc), check those as well. HTH, Alin