Optimisation of unpivot/insert code
Hi all,Trying to optimise the below query, I believe it's do with the estimated rows on the unpivot using Supratimes this seems to be the only sticking point.The query below is an example replicating...
View ArticleTransactional log file restore job
Dear All,I have a database which gets refreshed on the daily by restoring 1 transactional file log, at the moment it is done manually but I'm trying to create an automation job which would get the...
View ArticleHow to systematically manage a Big List of Queries and Tables in SQL Server ?
Suppose someone has to work on a lot of different SQL Server Databases which have got a lot of Tables and Queries / Views inside them.After a period of time, it becomes very difficult to remember...
View ArticleHow to easily test SQL Codes online and share them with others ?
I am looking for some online service like - SQL Fiddle - http://sqlfiddle.com but with better features. SQL Fiddle limits the database size to a small sample and does not have any proper user features...
View ArticleNeed Help in Recursive Query in SQL using CTE
I need help in sql recursive query, for example purpose i m providing sample table with insert scriptCREATE TABLE Details(parentid varchar(10), DetailComponent varchar(10) , DetailLevel int)GOINSERT...
View ArticleUser Defined Table Type with calculated columns possible index corruption...
HI folks,A few weeks ago one of my colleagues asked me about a “peculiar” message when tried to use a table variable declared as the user defined table type. The table type had a couple of computed...
View ArticleQuery Optimization/Cleanup
The query returns the data that I need, but it looks rather sloppy. There are only a few hundred rows in the table at the moment, but expect to reach hundreds of thousands. Performance is a concern in...
View ArticleNeed help to build recursive query
Hi There,Sample Data : [code="sql"]create table #sample (Mainstream int, Substream1 int , substream2 int , [status] varchar(10))Insert into #sample values (1,2,4,'Valid')Insert into #sample values...
View ArticleFinding NULL in CASE Statement
The below code returns a NULL for all the Differential backups. I am trying to return the word Differential when there is a NULL because I can tell from when the NULLs occur that those are my...
View ArticleAuthorization matrix
Hello, I am trying to develope a authorization matrix for cpmpany of 75 employees, with different roles and permissions for roles to some applications like CRM , diiffrent folders,databases etc. I...
View ArticlePainful datetime conversion
I have a very awful table structure that I have to deal with. This is in an ERP and I can't change the tables...yes I know how completely horrible this is. This system stores dates and times in...
View ArticleCursor Clarification
Hi allI have a query which has data injected into it, which is returned from a user defined function. This is very slow and I'm looking for a way to speed it up.The suggestion I'm working with is to...
View ArticleBest design for multiple validation checking of data
Hi all,I'm new to SQL and have done some simple reports before. Now I want to do something to help with error checking in my company. For this we have a selection of different tables and the data needs...
View ArticleThe multi-part identifier "dbo.ufnGetAccountingEndDate" could not be bound.
Hi Folks,I am experimenting with functions on a SQL Server 2014 box and with the AdventureWorks2014 database.Within the database is a function called 'ufnGetAccountingEndDate' and no parameters need to...
View ArticleShow sum in the last row
hello all,I have a table with some rows and columns what i want is i want to Show sum of particular column in the last row.this is my code.SELECT DISTINCT Cluster.ClusterName, Gruppe.GruppeName,...
View ArticleTable locking while insert statement
I have two tables for insertion in one transaction scope. Table one have 10 rows. After first table insert statement (not yet committed) if I run select on first table from other session, it holds...
View ArticleMemory-optimized queries using table scan instead of seek
I've been having some trouble getting a single-column "varchar(5)" field to reliably use a table seek instead of a table scan. The production table in this case contains 25 million rows. As impressive...
View ArticleHow to print state of running query to output?
I want print state of running query to output, because my query need long time to run.But print statement dos not work correctly!!Note: I cannot use "go" in my query!/* My query */print 'Fetch Data...
View ArticleCannot open SSRS 2014 Report Manager URL on Windows Edge Browser (Windows 10)
I was using Windows 7 and had SSRS 2014 installed.Having set up the inbound rule on Windows Firewall (port 80), to allow SSRS through, I was able to browseto the Report Manager URL, by opening up...
View ArticleQuery fails with invalid column name but succeeds as a sub-query with...
-- The 3rd query uses an incorrect column name in a sub-query and succeeds but rows are incorrectly qualified. This is very DANGEROUS!!!-- The issue exists is in 2008 R2, 2012 and 2014 and is "By...
View Article