Ashwani 的个人资料Ashwani Roy's BI Blog照片日志列表更多 ![]() | 帮助 |
|
|
1月26日 Dynamically creating Excel Sheets and populating data from SQL server tablesI came across this very interesting question on Microsoft Forums where in the developer wanted to Create an SSIS package which Loops thought a set of tables and create Excel files on the fly and Load data into it. There can be many ways to solve this including building a dot net custom component which creates excel sheet on the fly and then dynamically loads the data into it. Though I came across this cool SP that does this job really well and in very quick steps.
Here is how you can do this --
11月15日 What's New in SQL Server 2005 SP3Microsoft SQL Server 2005 Service Pack 3 (SP3) contains all the cumulative updates for SQL Server 2005, and fixes to issues that have been reported through our customer feedback platforms. These include supportability enhancements and issues that have been reported through Windows Error Reporting. Additionally, the following components have new or improved features. Read here for more http://download.microsoft.com/download/0/e/5/0e5697be-028a-4da6-89a7-c18a9a1ac3c7/WhatsNewSQLServer2005SP3.htm Batching Update StatementIt is a very good idea that you a Batch Update to stop Lock Escalating to Tablock. If you are using SQL SERVER 2005 you can do UPDATE TOP N 1. Add a clolumn ISUpdated in the same table (or make another table which has all the empids and ISupdated column) Code Snippet update Top (@TopN) employees set payrate = payrate * 1.1 WHERE IS_UPDATED = 0 2. after this you need to update ISUpdatedFLag. --IN any SQL version you can do this--------- If I was you I will do this 1. Create another table that has PrimaryKey of the table you are trying to Update , UpdateFLAG Lets say you are updaing employee table then make a table emp_temp (empid int,isupadted bit) 2. Now I can say --Bring the first Batch-- insert into emp_temp select top 1000 empid,0 from Employee A LEFT OUTER JOIN emp_temp B on A.empid = B.Empid WHERE B.Empid IS NULL //Get those employeed which are not yet there in the emp_temptable IF @@rowcount > 0 --- if there are new records to update Begin
END ---------------------------------------------------------------------------------------------------------------------------- Another way if you have Datecolumn in the table (which I hope you would) you can say update mytable set col1 = xxx................ where createdDate between Date1 and Date2 ---- again you can make batches of dates like Date1 --- date2 date3----date4 Hope this helps there is an article here. I have myself not tried it but you can give it a go 11月13日 Before Performance tuning ...When you are trying to perf tune some SQL query you must first clear the Cache and Buffers. SQL server caches the Plans for the query it has already executed and thus you will not get correct TIME performance counters. In order to clear database engine Cache you can do this DBCC FREEPROCCACHE Here a code snippet from MSDN USE AdventureWorks;
Here is the result set.
-- Remove the specific plan from the cache. DBCC FREEPROCCACHE (0x060006001ECA270EC0215D05000000000000000000000000); Clearing all plans from the plan cacheThe following example clears all elements from the plan cache. The WITH DBCC FREEPROCCACHE WITH NO_INFOMSGS; GO DBCC DROPCLEANBUFFERS --> to test queries with cold buffer cache more info :- http://msdn.microsoft.com/en-us/library/ms187762.aspx DBCC FREESYSTEMCACHE('ALL') -- Is same as DBCC CLEANPROCCACHE but this is only available in 2005 Summary :- You should always do the performance testing of the queries with a cold cache in order to get correct performance counters SQL Nexus and PSS DAIGThere are times when all of us struggle to fin out the performance bottlenecks. I was playing around with PSSdiag and I realised how cool but underrated it is.
You can go here and download SQL Nexus and Play around with it. 11月12日 Performance Problem while reading from Linked serverSome time back I answered a post on forums about performance issues with linked server and few days back I was under the same situation. There are couple of things that you can do 1.Create a stored procedure on the remote database and have it return a record set, being a subset of the remote tables, which is then loaded into a local temporary table. It can then be indexed as needed. eg you have SP1 on you local server to get data. It needs data from linkedserver.table1 and table2 Create SP2 on the remote server to give you this data into a temp table . Index this table and let SP1 read from this table. 2. Try to optimise your SP by getting least data from the linked server but using proper filtering etc. (even though it sounds obvious , as the linked server is normally not your server you don't know the data model well enough and sometimes due to improper filter criteria you bring in more data than you need) 3. if there is not improvement even by now... you might look at possibility of pulling some data to you server using SSIS and then use the data from your own server. ( This depends on the system that you worked for and it was possible for me to get half of the data that I needed by a package as it was not transactional data and so I did not have to JOIN to linked server tables to get them). |
|
|