T-SQL help on Total Cost
Hi i have a querey select pr.PurchaseRequestId,prl.TotalCost,pr.DateRequested from dbo.PurchaseRequest as pr left join dbo.PurchaseRequestLineItem as prl on pr.PurchaseRequestId=prl.PurchaseRequestId...
View ArticleOver Partition with multiple duplicate identifying columns
Greetings all,I'm facing a rather difficult situation with an over partition piece of code I wrote to remove duplicate records from a table. Basically, we have a table named "Record" which contains...
View ArticleSql Unique Column
Hi There,I am a new bee to Programming, so I am writing a Vb.net Program with relevant to SQL !!So I have a table Company, and that company have many aircrafts and all the aircrafts are unique, If the...
View Articlesql query select
when i execute stored pro and give parameter 1,4,2,8,3 now i execute result show like this12348but i don't want to show in sequence when i give parameter 1,4,2,8,3 result show like this14283how can i...
View ArticleProblem with cursor, I found out another way but I'd like to understand where...
Hi everyone, a question...I have this table History2 for athlete[NOME2] [varchar](50) NULL,[BL2] [int] NULL,[AM2] [int] NULL,[SX2] [int] NULL,[per] [nvarchar](5) NULLOutputM.P. 7 8 11 nullA.R. 7 7...
View ArticleSQL Collation issue?
Hi AllI have the below 2 queries:--Query1 select * from table1 where lower(column1) like '%der%' --Query2 select * from table1 where column1 like '%der%' The first query returns a result but the second...
View ArticleFind The Parents, Child and Associated Id in a SQL
Hi,I have to find the parent, the child and associated Id with which it is grouped in a table.For example:ID / Parent ID / Relation1/0 / 02/1 / 13/ 4 / 14/0 / 35/3 / 36 / 2/ 2If I were to input the...
View ArticleBest Practices - SQL Code in Application Code or Not?
I have recently started a new position, where the main project is written mostly in FoxPro. There is some (increasing) effort going on to move it to .NET. As the project is still in the early stages,...
View ArticleDENSE_RANK() : Start ranking by a no. of my choice and not by 1 ... Can I?
Hi,Can I rank my records by a starting no. of my choice instead of 1?Please let me know if this is possible.Regards'In Persuit of Happiness' and ..... learning SQL.
View ArticleTo Find columns with no data.
Hi, I want to check in my results, how many columns doesn't contain data at all(may be blank) and want to list the column namesThanks in advance.Thanks.
View ArticleHow to drop all columns in all databases starting with... AND how to drop the...
I am trying to drop some columns from all tables in a database. I can generate multiple scripts on all databases (see below) but how can I now execute them automatically without copying and pasting...
View ArticleHow to send list of failed jobs through email using sp_send_dbmail?
I have 2 tables as PackageErrorLog and PackageLog with columnsPackageLogID ErrorDescription LogDateTime ----> PackageErrorLog 1 XXXXX...
View ArticleLast Recent Record with Value from other column
drop table #abc CREATE TABLE #ABC ( CompnayID INT, TrainingCompanyID INT, CategoryID INT, ItemID INT, LastTrainedBy VARCHAR(40), LastTrainedOn DATETIME ) INSERT INTO #ABC VALUES (1, 1, 4, 2, NULL,...
View ArticleBalance Snapshot and Lag Window Function
Having read the books - I understand that a daily snapshot should - by definition - be taken every day. I am in the specialty credit card space. Ours is not a daily use card. Typically - our card is...
View ArticleHow do I optimize this simple query
Hi everyone,I am using the following query in an application. Basically, the query shows account balances for the last 2 years. I need to get the same query to show data for the last 3 years. I can add...
View ArticleAre you a technology guru? Show us your solutions and become the T-SQL Guru...
TechNet Wiki is looking for and celebrating the best of the best!Is that you? Do you consider yourself an expert, or authority on T-SQL?Show us your forum solutions and become MICROSOFT TECHNOLOGY GURU...
View ArticleNon cluster index setup Help
Hi Friends, i have below kind of table strucutureTable_A (table_a_id int (PK), col_1 varchar(50), Col_2 varchar(50), Col_3 varchar(50),COl_4 varchar(50))Please find below sample query SELECT a.* FROM...
View ArticleDATEDIFF II
Hello,Some question has already been answered here, but I'm still getting a hard time, maybe you could enlighten me... (First answer:...
View ArticleAccessing local instance error
Hi, I have ssms in my local and generally I connect to the servers which my team says. Now I want to connect to my local itself to do some development work but I'm unable to do so .I tried (local)...
View Article