Red Gate forums :: View topic - Database specific tags
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Multi Script 1
SQL Multi Script 1 forum

Database specific tags

Search in SQL Multi Script 1 forum
Post new topic   Reply to topic
Jump to:  
Author Message
Roust_m



Joined: 28 Apr 2009
Posts: 4

PostPosted: Tue Apr 28, 2009 10:00 am    Post subject: Database specific tags Reply with quote

Hi,

I think it would be very useful to have a feature to automatically replace some text inside the TSQL script depending on the database it will run against. Suppose I have three databases called MyDB_US, MyDB_UK and MyDB_FR. The generic script for all of them would contain:

SET @JOBNAME = N'{country_code}_MyNewJob'
EXEC msdb.dbo.sp_add_job @job_name=@JOBNAME, ...

At the time of execution {country_code} tag would be replaced to "US" for MyDB_US, to "UK" for MyDB_UK, etc.

Are there any plans to implement such feature?

Thanks.
Back to top
View user's profile Send private message
Colin Millerchip



Joined: 31 Oct 2007
Posts: 66
Location: Cambridge, UK

PostPosted: Fri May 01, 2009 9:33 am    Post subject: Reply with quote

Hi Roust_m,

Thanks for the feedback, which we'll consider for the next release.

Best regards,


Colin.
Back to top
View user's profile Send private message Send e-mail
Linda Hawksworth



Joined: 25 Jun 2007
Posts: 192

PostPosted: Tue May 05, 2009 10:20 am    Post subject: Reply with quote

In the meantime, you can do what you want using T-SQL:

DECLARE @CURRENT_DB NVARCHAR(128) ;
DECLARE @COUNTRY_CODE NVARCHAR(2) ;

SET @CURRENT_DB = DB_NAME() ;
SET @COUNTRY_CODE = SUBSTRING(@CURRENT_DB, LEN(@CURRENT_DB) - 1, 2) ;
SELECT @CURRENT_DB AS 'Current DB',
@COUNTRY_CODE AS 'Country Code' ;

Let me know if this suits your requirements.
Back to top
View user's profile Send private message
Roust_m



Joined: 28 Apr 2009
Posts: 4

PostPosted: Wed May 06, 2009 5:29 am    Post subject: Reply with quote

Yep, similar to what I am doing now, but this does not cover the whole thing, as there may be a job step parameter which is country specific.

E.g. for UK it would be:
exec spMySP 'Products','UK'
for France:
exec spMySP 'Produits','FR'
for China:
exec spMySP '產品','CN'

and the generic script would look like:
exec spMySP '{Product translation}','{Country code}'

therefore it should also handle unicode.

I understand that I can build a replacement table in the begining of the script. E.g.: if the last two characters of the database name equal to 'FR' then replace {Product translation} with 'Produits' and '{Country code}' with 'FR', but it would be easier to build separate scripts.

It would be ideal if the app could search for the tags and prompt me to set the replacements for each database I am running the script against.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6674

PostPosted: Wed May 06, 2009 11:22 am    Post subject: Reply with quote

Hello,

I have sent a link to your private messages to a build of Multi Script that can handle Unicode.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group