October 3, 2012 at 3:08 am
[font="Courier New"]Hi All,
I am monitoring application performance using SQL script where i am using several performance counters. My Counter_Matrix table is in other dabasse where i am inserting data. Now I want some modification in script i.e. no matter where ever my Counter_Matrix table is I want to run that script so that it can insert data in that table only...
Ex: If I run script in DB "A" and my Table is in DB "B" then also I want script to be excuted sucessfully and insert records..[/font]
October 3, 2012 at 9:27 am
bhushan_juare (10/3/2012)
[font="Courier New"]Hi All,I am monitoring application performance using SQL script where i am using several performance counters. My Counter_Matrix table is in other dabasse where i am inserting data. Now I want some modification in script i.e. no matter where ever my Counter_Matrix table is I want to run that script so that it can insert data in that table only...
Ex: If I run script in DB "A" and my Table is in DB "B" then also I want script to be excuted sucessfully and insert records..[/font]
You description does not really explain very well what you are trying to do. I think you may want to look at simply using a fully qualified reference to tableB. (database.schema.object)
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 3, 2012 at 4:03 pm
bhushan_juare (10/3/2012)
[font="Courier New"]Hi All,I am monitoring application performance using SQL script where i am using several performance counters. My Counter_Matrix table is in other dabasse where i am inserting data. Now I want some modification in script i.e. no matter where ever my Counter_Matrix table is I want to run that script so that it can insert data in that table only...
Ex: If I run script in DB "A" and my Table is in DB "B" then also I want script to be excuted sucessfully and insert records..[/font]
3 part naming convention would probably do the trick.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 4, 2012 at 6:19 am
Some thing like:
IF DB_NAME() != 'LogCentralDB'
BEGIN
INSERT INTO LogCentralDB.dbo.Counter_Matrix
SELECT * FROM dbo.Counter_Matrix
WHERE ...
END
Please note: LogCentralDB database name is just used as an example...
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply