Extra join is killing query
Hi GuysI have a query that takes around 1 second to run until I join another table then it takes around 6 minutes.There is nothing unusual about the table I am joining, it joins without drama in other...
View ArticleGetting error message in sql server
Hi All,I need to pass the messages coming from sql server to the asp.net application so I have the following scriptCREATE TABLE tbl_sample( [ID] INT, [NAME] VARCHAR(10),)GO\I am trying to insert values...
View ArticleBCP and Bulk insert of special characters
Hi all, I'm testing, with SQL 2014 on the same DB, a procedure that extracts data from a table into a file and Loads data from that file into a different table which has the same columns as the initial...
View Articleneed to understand the bulk insert
Hi all, I'm testing a procedure on a combination of different Operating Systems with different versions of SQL express with the same data on all environments.Win7 + SQL2014 --> bcp queryout to a...
View ArticleSQL server email in table format
EXEC msdb.dbo.sp_send_dbmail @subject = 'Job Summary', @profile_name = 'SQL SMTP', @recipients = 'email address', @body = @body, @body_format ='HTML', @query = ' DECLARE @body NVARCHAR(MAX) SET @body =...
View ArticleUser Can delete rows from a table by Calling Stored procedure SP While User...
Hi I am confused . I deny Delete Permission on a table for a user. But user also delete records from the app !!! I checked it from sql server console : I login with the User. Then execute a stored...
View ArticleWindow Functions - Performance when only care about last value in window
I am writing some scripts to calculate mean (avg) stdevs count and percentile_cont for some dataI am partitioning over multiple columns e.g. partition by year,month, day order by valueMy question is am...
View Articlebcp out query result to sql file
Hi All,I have the below query which gives me statement to apply the login name, SID and PWD and that I statement I can apply to Dr and secondary server. Incase of failover there will be no connection...
View ArticleSelect records start with %
Hi,I need to select records in column that start with '% ' -- %space e.g. column A = % mytestI tried select column name with like operator but it select records who start with % and ignore spaceselect...
View ArticleBulk insert a fixed width file
I wasn't sure where to put this topic so I put it here since I figured it is a question that would apply to virtually any version even though I am using SQL Server 2005.We have a vendor that sends us a...
View ArticleTransition from SQL server 2000 to SQL server 2014
Hello All,We're in the process of moving our SQL server 2000 to SQL server 2014. I've created a new instance on the SQL server 2014 along with the linked server to SQL server 2000. It's going to be a...
View ArticleMultiple Columns to appear on One Row
WE have a query which pulls revenue by country and client for the last 3 years. Right now we have each year being reported in separate columns but we would like to have the revenues for each year for...
View ArticleSET ANSI_NULLS OFF DILEMA
I recently moved to a new shop where they acquired a legacy system (source code and all) and is maintaining it.The Database is a mess: lack of FKs, indexes and all Id are decimal(18,0) instead of (most...
View Articlehow to update values based on column into multiple columns in another table
I have a table #vert where I have value column. This data needs to be updated into two channel columns in #hori table based on channel number in #vert table. [code="sql"]CREATE TABLE #Vert (FILTER...
View ArticleHow Do I Select Data From Table With A Particular Column Priority
DECLARE @Table TABLE(minv_code INT, alert_msg varchar(10), alert_time Datetime) INSERT INTO @Table VALUES (873939, 'Reverse', '7/24/2015 3:31:18'), (873939, 'Tamper', '7/24/2015 3:30:00'), (873939,...
View ArticleNeed help in Pivot Table with Column Names to Rows.
Hi,Need help in Pivot function. I have a table with following rows.[code="plain"][b]FY REVCODE Jul Jun [/b]2015 BNQ 1054839 20000002015 FNB 89032 10000002015 RS 1067299 3000000[/code]I am looking to...
View ArticleLeft outer join
Hi AllWe have upgraded our MS SQL server from 2008 to 2014 and one of the SP isn't working. Our SQL guy has left and I'm trying to work out the issue. The SP seems to using an old method for Left Outer...
View ArticleWhere the bottle neck in a report
Hi guys We have a web application. We deployed All Servers (Data server + Web server) On One data center. Our Web app have some Main and Heavy reports . (WareHouse...
View ArticleMerge replication does not work with non-default conflict resolver
I have been evaluating merge replication, 'push' subscription on SQL Server 2014. If the default resolver is used (I refer to @article_resolver parameter of sp_addmergearticle), all seems to work as...
View ArticleLEFT JOIN with a large partitioned table
I've been seeing a very odd SQL Server 2014 behavior, and wondered if anyone has seen it. I have a query that has a left join with a large partitioned table. The partitioned table has 10s of millions...
View Article