Correlate cache plane entry with originating application or connection?
I noticed some ahoc / single use cache plan entries (dm_Exec_cached_plans) that could stand to be parameterized. However, I am unsure of which app (we have tons of apps that touch sql). Is there a...
View Articlehow do i know what level locking is done on the object
How do I know what level locking is done on the object by my query?Thank you
View ArticleAudit Trail
I have a database which is used for a web application(not website). For each web application user, Is it advisable to create separate db user?Now I have a single db user to access from the web...
View ArticleStored Procedure looping
I am looking for the ways to reduce the looping for the below stored procedure. This takes around 30 minutes to loop around 30,000 records. Let me know if there are ways to rewrite the stored...
View ArticleInclude table to aggregated update statement
I want to include receipt_link_id table to the below statement how can I achieve it???UPDATE#arr SET rec_id =(SELECT max(dbo.recpt_status.recpt_id)AS aggr$1FROM dbo.recpt_status WHERE...
View ArticleTypes mismatch between the anchor and the recursive part
Hi, When I run the below ReportServer query from ReportServer database query works fine but when changed toIone
View ArticleReportServer query when run from a user database throws error
Hi, When I run the below ReportServer query from ReportServer database query works fine but when changeIone
View ArticleEnumerate rows in a SQL QUERY with Counter
Hello I have a query with UNION Select ‘input’ as Type, Name, City, date form Table1union Select ‘Output’ as Type ,Name, City, date from Table2ORDER by date As result, I would like to have a...
View ArticleDifference betweem temp table and CTE as performance wise?
Hi Techies,Can anyone explain CTE and Temp table performance wise. Which is the better object to use while implementing DML operations.Thanks in advance.RegardsCham bee
View ArticleMsg 137, Level 15, State 2, Line 29 Must declare the scalar variable...
USE [NC_DB] GO /****** Object: StoredProcedure [dbo].[S_EDIT_USER] Script Date: 12/23/2013 12:32:44 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[S_EDIT_USER] (...
View ArticleHow to insert data into a table only when data has changed its value (when...
I wish to insert data into a table only when the value of the inserted data has changed. Thus, in a time series, if the value of the data at time, t-1, is 206 then if the data to be inserted at time t...
View Articlestored procedure results to a txt or csv file using SQL Server agent JOB
hi all,created a job and with TSQL script EXEC xp_cmdshell 'bcp "exec sp_who2" queryout "C:\job results\abc.csv" -T -c'the job execution was successful and am getting the required data but the data was...
View ArticleImproves Query Execution time
Hi All,I have this query which is running on a database whose few tables are partitioned and few are not (there is a valid reason for few tables not to partition-- Please do not ask why)This Query...
View Articlehow can we find the most usage and lowest usage of table in Sql Server by T-SQL
how can we find the most usage and lowest usage of table in Sql Server by T-SQLThe table has time stamp column StartedOn datetime EndedOn datetime
View ArticleSQL Server 2008 R2 Date functions on NVARCHAR & VARCHAR data type
Hi, I am using SQL Server 2008 R2 and was wondering if Date functions could be used with NVARCHAR & VARCHAR data types. I created 2 Date columns one of NVARCHAR(10) an the VARCHAR(10) was able to...
View Articleconverting varchar to datetime where date field is missing
Hello Sir,i have a column with varchar datatype values like '2013/12','2012/11' where date field is missing. i want to convert it as datetime at runtime so that i can use datetime related function. Is...
View ArticleT-sql - finding all sales orders that have similar products.
Hi,I've the following table and the data in it as well as per below. My question now is, I've to find all orders that have similar products placed in the sales table.So looking at the data entered, I...
View ArticleMigrating legacy code to 2008 R2 standards...
Hi , I'm trying to rewrite the below code which uses tmp tables developed in 2000 version of SQL to 2008 R2 .any help in tuning query is appreciated.. -- Load all ip_id and skill combinations from...
View ArticleLooking for a script which gives...
Hi All,I need a T-script for sql 2005 and 2008 which should give output as:Looking for a script which gives...
View ArticleHow to export SQL data to Excel SpreadSheet using SQL Query?
HiIm using this query to select ,calculate and format data like Refer here for more understanding:- Select DateAdd(Hour, DateDiff(Hour, 0, RowDateTime), 0) As RowDateTime, Avg(Meter1) As Meter1,...
View Article