question

munna avatar image
munna asked

Client instancing

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.
sql-server-2008
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image
Fatherjack answered
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.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

munna avatar image munna commented ·
yes we have the references in the database objects, ( stored procedures, functions, views)...
0 Likes 0 ·
alinselicean avatar image
alinselicean answered
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
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Håkan Winther avatar image
Håkan Winther answered
You can try to use synonyms. I am not sure of the performance implications though
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.