TSQL Merge - Multiple statements after THEN
I'm using a MERGE statement to merge two tables.When I have a match in keys, but the data is different I want to inactivate the old/existing record with an update statement where I fill the EndDate...
View ArticleSame query with different execution plan
Hello All,I wonder why does sql server create different execution plan for these below queries ?Thanks.
View ArticleHow to get running SQL query 2008r2
HiI am faultfinding multiple slow queries initiated by SharePoint 2010 crawls.Is there any way in SQL management studio where i can display the current running queries?I'd love to get my hands on the...
View ArticleInserting new columns based on the condition!
Hi guys, I have a very simple query like the following… -------------------------------------------------------------------------------------- SELECT table2.column_code2,...
View ArticleShould We Assist with Class Assignments?
My answer is no. What is yours?Here is recent...
View Articlechecking existence of data before inserting is good or direct insertion is goog
Dear all,I have one big stored procedure which generates heavy data, i show people are checking if records exist then only they insert else they do not . what i noticed, they can directally insert.is...
View ArticleProblem with a Sub-SELECT statement. Need Help...
Hi there everybody. First of all, the following DB schema is not mine and I have to work with it, and I'm not allowed to modify it.Let's say I've got 3 tables :- A list of Persons. - A list of...
View ArticleOpenrows set command failed while inserting data from .txt file using Bulk of...
Hi Team,The openrowset command failing on importing the file from .txt file.The table structure where the data to be loaded.CREATE TABLE [dbo].[tblAvayaCMShagent_Test]( [Row_Date] [datetime] NULL,...
View ArticleColumns to rows
DatasetBatch#Check# VRR 10000814028770003608 VRX 28745814028770003608 VRY 24512814028770003608 VRZ 15114814028770003608 VRR 2451814028770003608 VRO 29101814028770003679 VRP...
View Articlesum up between certain dates-tsql query
Hi, We have a following scenario, DATEMONTH startMONTH endIS BUSINESS DAY2014-02-232014-02-012014-02-2802014-02-242014-02-012014-02-2812014-02-282014-02-012014-02-281For example, if date 2014-02023 is...
View ArticleMulti Product Affinity
Hi allI am trying to do some Multi Product Affinity analysis. Database is sql 2008. The Business Question isWhen customers purchased product A and Product B in one transaction, what other product/s did...
View ArticleFind the closest matching Char value
Hi all,I am looking for a select statement that will compare the alphanumeric value of my input string (Char(10)) and return the closest matching alphanumeric value from my table (also Char(10)).If my...
View ArticleCombine 2 Queries (from SAME table) into a SINGLE query
I have this two queries (from SAME table), and want to combine into one SINGLE query, how?How can we use CASE WHEN THEN for such situation? Query1:SELECT t_inner.*, Floor(t_inner.ProductiveTime/ 3600)...
View ArticleHow can I debug a Bulk Insert error?
I'm loading a bunch of files into SQL server. All work fine, but one keeps erroring out on me. All files should be exactly the same in structure, but they have different dates, and other different...
View Articleselecting table columns as table rows
i have table structure like , please see the figure.For each company for each account i have 12 period values as columns.i want to extract 12 periods as 12 rows for each company for each account.can...
View Articlehow to get information of employee whose salary is less than the average...
how to get information of employee whose salary is less than the average salary of department
View ArticleMultiple Field field search with multiple resultset
I have 10 controls in a form and when a control is selected the rest of controls are re-populatedHere's my table structure...
View ArticleProblem with PATINDEX function for case-sensitive information
Hi, My database is not case-sensitive, but I want output like... SELECT patindex('%[A-Z]%','gaurang Ahmedabad') The output should be first occurrence of uppercase A to Z, so output should be 9 it...
View ArticleDMV use Cross Apply and too much result
HiHere are my code for query DMV, but some column Is repeated, how can I filter it (last_exection_time) ?I just wnat find T-SQL query information(only select), and it must include query text、targert...
View Article