Delete Duplicate with smaller index
I have a table with the following:IDORDERP_ID123401234561234065432145670456123456714561234567245612345670987654456719876544567298765478900495874789001234987890068425978900154980I want to say delete all...
View ArticleConvert Comma separated values to different rows for multiple Columns
Hi All,I need some help in getting the output in a specific manner. After some searching on the web, I found the solution if we have only one column that has comma separated values and need to convert...
View ArticleAutomatically FTP a SQLServer export at regular intervals on Windows Server 2008
I'm getting fairly familiar with linux systems but we had an employee leave that left some Windows stuff for me that I don't know anything about. Of course, it needs done urgently. It seems like it...
View ArticleOracle statement to SQL Server
Hi All,I have a oracle statement, I need same logic in SQL Server. I know in SQL server we use CASE statement instead of decode, but I don't understand this oracle statement Select...
View Articlehow to update the r_ord for r_name (A & B)?
hello experts,i having a below table @tbl,DECLARE @TBL TABLE (UID INT, R_ID INT, R_NAME VARCHAR(5), R_ORD INT) INSERT INTO @TBL VALUES (1, 25, 'A', 11), 2, 25, 'B', 13), 3, 25, 'X', 5), 4, 20, 'A', 9),...
View ArticleSQL Query to create a Time Dimension at 15 mins granuality
I need a query to generate Time Hierarchy for Year, Half Year, Qtr, Month, Week, Days, Hours, 15 minutes interval Pls share the query to generate the same or Excel sheet with the data. ThanksAnky
View ArticleSplit a comma
Hi guys, I'm pratically fighiting with SSIS. I got in a table 100000 rows (string) as 10.36 236.25 56.77 and so on but I got also ( and that's qhy I'm fighting) ten rows as Paris,52.36 Rome,18.22...
View ArticleSQL Server 2014 memory-optimized table performance
Memory-optimized table query appears to be slower than regular table query. What's wrong? Thanks.Kalman Toth Database & OLAP Architect Free T-SQL ScriptsNew Book / Kindle: Exam 70-461 Bootcamp:...
View ArticleSQL Server 2014 New T-SQL Features
I have seen the following new T-SQL features:1. In-memory OLTP tables.2. Inline specification of CLUSTERED and NONCLUSTERED indexes is now allowed for disk-based tables.3. The SELECT … INTO statement...
View ArticleSelect all values from Rule in Store Procedure
HiI have a rule like this CREATE RULE[dbo].[Rle_Currency_Lst] AS @ListIN ('PKR','USD') GONow i want to make simple "Currency List" report for which i need to select values from above rule in Store...
View ArticleQuery Error - Schema Does Not Exist
I get the following error when creating stored procedure:Msg 2797, Level 16, State 1, Procedure SearchAllTables, Line 90 The default schema does not...
View ArticleSelect by Max(predictiondate) and by Days Difference in a single Sql transaction
Imagine I have a Truck to transport goods and give to my customers some predictionsI have the following predictionsdate of prediction City Day...
View ArticleDatabase Query
Good DayI have two table, one called ExpenseCategory and the other one called Expense. How do i write a SQL Statement that gets all expense together with their categories all in one column and with...
View ArticleComputed column in SELECT CASE t-sql
I've got a computed column:BilledAmount =CASEWHEN CoverageItem in('MED','RNB','LAB')THEN ISNULL(SUM(ISNULL(hb.BilledAmt,0)),0)ENDFROM HospitalBill hb with(nolock) Basically, what it does is sum up the...
View ArticleFind AVG : Exclude values which are 0 while finding AVG
Hi,I have a SQL Logic like I have mentioned below. case when ( [ParameterName] = @ParamName OR [ParameterName] = @ParamName3 OR [ParameterName]=@ParamName4 OR [ParameterName]=@ParamName5)...
View ArticleBest Query Approach
I have a scenario to display data from 2 tables combined. First table Named 'DayTable' consists of daily plan and actual. Second table named 'MonthTable' consists of Monthly plan and actual. I need to...
View ArticleT-SQL Guru needed! Apply within...
April fools out of the way, now let's find an April genius!The name "April" is derived from the Latin verb "aperire", meaning "to open" in reference to being the season when trees & flowers start...
View Articlewhich item has been sold more than once to the same customer by the same...
which item has been sold more than once to the same customer by the same employee ?my tables are[order details]=(orderid, productid)[orders]=(orderid,customerid,employeeid)
View ArticleMatrix output
HI,I have data something like this: IDTypeCode value 1termterm 1 2term term 2 3Channel CHNRetail 4Channel CHNRetail90 5Drug DRGBrand 6Drug DRGGeneric Output: i need ALL...
View Articlewhich item has been sold more than once to the same customer by the same...
which item has been sold more than once to the same customer by the same employee ?my tables are[order details]=(orderid, productid)[orders]=(orderid,customerid,employeeid)
View Article