Return values not seen in previous records
I'd like to be able to return Code values below that have not occurred previously (ordered by ID). I have a feeling it's going to involve a ROW_NUMBER() and CTE, but I can't quite put my finger on it....
View ArticleDistinct Cummulative count
I need to calculate the distinct Cummulative count for the incremental monthsAs shown belowMonth PersonName 7 sam 7 kim 7 tim 8 sam 8 tom 8 rex 8 ram 9 sam 10 Robo/p :Month CountPerMonth...
View ArticleHi Experts
How to convert a number 41330 into dateformat yyyymmdd (20130311)??Any insights would be helpful!
View ArticleSyntax error declaring variables within trigger
I'm writing a trigger that when a new record is added to one database (basically a new customer being added), it then adds some of those details to a second database which is used by another internal...
View ArticleHow to debug a stored procedure in sql server 2012 ?
whenever I do a change to a stored procedure and then run the alter proc againafter that I place a break point on the exec stored procedure and try to step into the code SQL management studio starts...
View ArticleHow to use array list with fixed values to insert record in trigger
I have a list of number 1,30,40,45,60 . These numbers are not being changed so I don't need to keep in a table. So have to create a after insert trigger for AsBegin@list = 1,30,40,45,60 // Array...
View Articlecomplex query
I am trying to get following result set out of single column. In a column when it hit a particular value in columnA it will change column B value Table AColumn...
View ArticleData Type
Hi all, I've heard that you should not store dates ie "02/02/2014" as strings and they should be stored as datetime.Can someone explain please? Would this cause me any issues, I don't see any.....
View Articlelooking for CURSOR replacement, please suggest!
Hello Experts,I having some master tables "#ACTION_MASTER" & "#RPT_MILE_MASTER" and a link table "#ACTION_MILE_RPT_LINK" showing their relationship.And again I having a derive table "#TBL" to...
View ArticleUpdate one table based on condition from another table using date ranges
Hello!I have two tables:DateRange (consists of ranges of dates):StartDate FinishDate Condition2014-01-02 2014-01-03 true2014-01-03 2014-01-13...
View Articleupdating result set in a single statement
Hello All,Is it possible to update a result set in a single query? UPDATE (SELECT * FROM [TestEnvironment].[dbo].[Table_1]) as a SET a.col1 = 'abcd' WHERE a.col2=1Thanks and Regards, Readers please...
View Articlesplit a string using SQL
possible to split a string according to comma and separate in a variable. For example: @string = '11111,22222,33333',and put them in 3 variables
View ArticleTSQL Geography STGeomFromText Displaying Wrong Result
I'm trying to write a code which will tell me whether point is inside polygon or notDECLARE @Latitude varchar(20) = '41.694110' DECLARE @Longitude varchar(20) = '44.833680' DECLARE @g geography;...
View ArticlePartitioning Advice on PRIMARY FILE GROUP
Hi,I wonder if you can help. I would like some advice on partitioning within the PRIMARY file group. Basically I have a lot of experience on partitioning and in the past I have followed best practice...
View ArticleLeft Outer Join on same table clarification
HI,I have a table that gets populated from 3<sup>rd</sup> party system. We don’t have control over it. So, the table has master record (master) and children. Master type is 78 and...
View ArticleSum Value with different date
Hi,DECLARE @FromDateDate = '2014-01-01' DECLARE @ToDateDate = '2014-12-31' DECLARE @PreFromDateDate = '2013-01-01' DECLARE @PreToDateDate = '2013-12-31' CREATE TABLE TXN (ID varchar(10),TxnDate...
View ArticleHow to check if a file exists in a directory?
Sorry to bother everyone with something so simple. I installed and ran the function from here.http://www.tech-recipes.com/rx/30527/sql-server-how-to-check-if-a-file-exists-in-a-directory/Just like in...
View ArticleHow can i get the least date in a column with another column ?
Hi All,we have a table like below.IDDate10017/14/201010018/20/2011100110/2/201210026/23/2009100210/14/201210039/16/2012100310/19/2013i want result like...
View Articledeleteing tempdb files
I am trying to delete a couple of tempdb data files and get the below errors. There are currently 4 tempdb files. I want to delete 3 and just keep one but I have tried the SSMS and t-sql and neither...
View Article