.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Why the Same sql query taking much more time in other server.

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :Sql Server
Hi All,   I have a sql query.. which is running absoulutely fine in the production environment. I restored the Prod DB to another server.. same hardware and software configuration as Prod server. But in that server the same query taking ____ lot of time.. What could be the reason ??SD

View Complete Post

More Related Resource Links

Restoring Database taking long time in SQL Server 2008 R2 -- some how urgent


Hi all

I have Database size 12GB in SQL Server 2005 and It is backed up.

Now I tring to restore Database in SQL Server 2008 R2(wizard)....it is not at complted after 2hours...still running.


any idea..or help appreciated..



SSRS taking a long time to run an MDX query



I have an MDX query which runs fine in the MDX Sample Application. It runs against an SSAS 2000 cube. In my query there is a recursion kind of a logic. It takes about 1-2 sec to run in the MDX Sample Application. My sample application is in the same server as my AS 2000 cube is. However when I run the same MDX from another server through BIDS (2008) it takes an unusually long amount of time to run. Most of the time it times out. :(

As a workaround I created 4 calculated members in my Cube itself (Initially these were used as members in my MDX). I thought that maybe the recursion logic is the culprit so I modified my MDX, removed the recursion part. But still from my SSRS it is taking a long time.

Any pointers to where I am missing the trick ?

Thanks in advance,


SQL Query is taking long time to run


Hi All,
SQL Query is taking long time to run in my report. It is using Clustered index seek when I am querying for 2 days on invoice_itemized table. It is returning 99 thousand records. It is returning  2524094 records and it is using clustered index scan when I am querying for one month. For one month It is taking 7 minutes.
Basically it is not using the index defined for the store_Id, status and datetime columns in the invoice_totals table. Can I force the sql query to use the specified index?

Please suggest me to improve the performance....

SQL Query

,Invoice_Totals.DateTime InvoiceDate
,Invoice_Totals.Discount InvDiscPercent
,Invoice_Itemized.LineDisc LineDiscPercent
WHEN Invoice_Totals.Total_Price <> 0 AND Inventory.ItemType=7 AND Invoice_Totals.Discount = 0 THEN ((Invoice_Itemized.PricePer * Invoice_Itemized.Quantity) * -1) / ((Invoice_Totals.Total_Price) + ((Invoice_Itemized.PricePer * Invoice_Itemized.Quantity) * -1))
WHEN Invoice_Totals.Total_Price <> 0 AND Inventory.ItemType=7 THEN ((Invoice_Itemized.PricePer * I

SQL Server 2008 query execution time is different if i execute it in management studio or from code

When I execute query from software which i wrote in c# it required lots of time to complete but if I execute exactly the same query from management studio it will be done in seconds. In both cases execution plan is the same. 

MDX Query in SSRS Dataset taking more time


Hi All,

I have  created report based on below mention MDX query ,but it will take more time say of 10 mins to execute.while other report having bulky data in their datset working fine.

Kindly suggest how do i optimise the Query so it will take less time



member [measures].[A]as

member [measures].[B]as
iif([Measures].[Avg After Call Work]=0,0,[Measures].[Avg After Call Work])

member [measures].[C]as
iif([Measures].[Staff Time]=0,0,[Measures].[CALLSHANDLED]/[Measures].[Staff Time])

member [measures].[AA] as ((STRTOMEMBER(@EmployeeEMPLOYEENAME)), [Measures].[A] )
member [measures].[BB] as ((STRTOMEMBER(@EmployeeEMPLOYEENAME)), [Measures].[B] )
member [measures].[CC] as ((STRTOMEMBER(@EmployeeEMPLOYEENAME)), [Measures].[C] )

 member [measures].[Rank_Avg_Handle]as
(filter ([Employee].[EMPLOYEE NAME].[EMPLOYEE NAME].members,

 member [measures].[Rank_Aft_Avg_Call]as
(filter ([Employee].[EMPLOYEE NAME].[EMPLOYEE NAME].members,
iif([Measures].[Avg After Call Work]=0,0,[Measures].[Avg After Call Work])>[measures].[

SQL Server Query request for start and end period of time


Hi all

I have event table where I need to select records between days. my statements look like

  CONVERT(char(8),Event_Table.Event_time,112) BETWEEN 'request start date' AND 'request end date'

The Event_time is DateTime format.


Now everything look fine except from if I need the statement to request the date between as Date_start and Date_End any time it run. The idea is to request a for start and end period of date any time the scrpt run. the script will be run as DOS batch file. 

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.

Extreme ASP.NET: Tools of the Trade: SQL Server Profiler and Query Analyzer


In my last column, I discussed Microsoft® Application Center Test and how it could be used to measure the performance of your Web application (see Extreme ASP. NET: Tools of the Trade: Application Center Test).

Rob Howard

MSDN Magazine August 2005

SQL Server: Build Apps that Provide Real-Time Information and Customized Content Using SQL Server No


The adoption of wireless devices continues to spread unabated, and organizations are looking for new ways to get in touch with customers through these new mobile devices. In the past, unsuccessful ideas such as push technology were used to send targeted information to customers. Now, SQL Server Notification Services uses the SQL Server 2000 database engine and the .NET Framework to promote a new breed of notification applications that will allow relevant, consensual communications to be sent to any subscriber device.Here the author provides an architectural overview of the core features that make up SQL Server Notification Services. Along the way he discusses how they can be used for pushing Web content.

Mark Brown

MSDN Magazine November 2002

Set hosted server time according to country.



I have hosted my website , but my vendor's server is lying in canada.But i have used all system.Datetime.Now() for date operations, whereas my clients are from india and it shows me 12 hours difference. How can i map this time zone? I don't want to store the client's machine time but only server end time.

waiting for your prompt reply.


Slow page load during a list query one time during the day


We have a monitoring tool set to check to see if the home pages for our 3 web apps load in under 60 seconds every 10 minutes.  All 3 web apps load in under 3 seconds on every 10 minute check except for one exception.  One check every day one of the web app's home page takes longer than 60 seconds to load.  This happens at 11:45PM when there is very little user usage on the environment.  The characteristics of this page are as follows: The only thing on the page is a list view web part which was added by the browser.  The page has not been customized with SPD or code at all.  The list that it pulls is a simple links list that has 281 items on it.  The view pulls all 281 items and displays them in sets of 100.  I cannot find any associated event in the server events and/or SharePoint ULS logs nor are there any daily sharepoint timer jobs running at that time.  Our full index happens at midnight with incremental happening hourly.  Our enviroment is 2 WFEs, 1 App/indexer and we have a separate SQL cluster backend.  

Could someone lead me possibly in the direction I should take next in my troubleshooting?   

Customizing the Content Query Web Part in SharePoint Server 2007

Walk through how to customize the Content Query Web Part in SharePoint Server 2007 to query content across multiple sites in a site collection and display the results in any way that XSL can support. Learn how to get similar results when customizing the CQWP does not meet your needs.

Just-In-Time Debugger error when opening SQL Server studio express

Hi,   I am new to these forums; hope I am posing in the correct forum   I have problem opening the SQL Server 2005 Management Studio Express. Getting the error below   'An unhandled win32 exception occurred in ssmsee.exe [5336]'   Searched in many forums but none of the suggestions resolved my issue..   I have re-installed .net 2.0, upgraded to 3.5 but still no luck either   Have re-installed SQL server management studio express again no luck   Deleted the shell folder from both documents and settings and in registry still have the same problem   Appreciated your suggestions to resolve this issue   Many thanks

Does SQL Server have to load and init statics every time a SQL/CLR managed proc is invoked?

We are working with SQL/CLR stored procedures, triggers etc and it seems that all assemblies we use are unloaded/loaded every time a proc or trigger or TVF is called. Is this true? Is there any way to retain data between invocations of procs? for example can I create some static struct or object that I can setup once and then just refer to after that, so that unless we terminate SQL server, the static data is always in memory? Thanks PS: This was originally posted here, but that forum seems to be rarely frequented.  

Query on XML datatype in SQL Server 2008

Hi All, In table I have column with XML datatype. I can able to read the below XML tag. SET   @Title = CAST(@XMLContent.query('data(root/chemicalName)') AS VARCHAR(50)) <root><chemicalName>Sulphuric acid</chemicalName></root> but how can I read (in SQL Server 2008) with multiple rows in it, and how to know the list of child nodes and data of it dynamically? <Root> <Row> < CurrencyCode>GBP</CurrencyCode> < CurrencyName>POUND (STERLING)</CurrencyName> </ Row> <Row> < CurrencyCode>INR</CurrencyCode> < CurrencyName>Rupee</CurrencyName> </ Row></
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend