Adding 0 Minutes with DATEADD

I'm looking at some opportunities for performance tuning in my database and I've come across a select statement with this where clause: WHERE GETDATE() > DATEADD(mi,0,[TimeStamp]) My question is, does it ever make sense to use DATEADD in this f...
more »

2017-06-20 15:06 (2) Answers

Importing Data from excel into sql server

I am trying to import data into sql server using ssis packages. I have a column named description and that has a cell having 690 characters. I am getting a truncation error as SSIS is not able to figure out the maximum length required. I tried chan...
more »

2017-06-19 20:06 (2) Answers

Incorrect syntax near the keyword

I can delete the data from all 3 table except for transaction. I'm not sure why as i used the same codes to remove its data. The error is: An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in ...
more »

2017-06-19 19:06 (2) Answers


I need your help, When I type something in the text box, it sends me the following error: "System.IndexOutOfRangeException" and Additional Information: "B.Nombre" . I don't know what it could be, I'm looking for the error even try with parameters an...
more »

2017-06-19 14:06 (2) Answers

SQL list into a range outcome

Considering a situation where we are provided with a list of account ids (say a table with account_id field (integer)) which has account numbers as shown below: account_id 1001 1002 1003 1008 1009 1010 1011 1050 1051 I a...
more »

2017-06-19 14:06 (2) Answers

SQL table and data extraction

I have never done SQL before and I been reading up on it. There is a exercise in the book i am reading to get me started, I am also looking up a website called W3School and the book is telling me to attempt the below; Trades which has the following ...
more »

2017-06-19 10:06 (3) Answers

Re-seeding a large sql table

Using version: Microsoft SQL Server 2008 R2 (SP3-OD) (KB3144114) - 10.50.6542.0 (Intel X86) Feb 22 2016 18:12:09 Copyright (c) Microsoft Corporation Standard Edition on Windows NT 5.2 <X86> (Build : ) I have a heavy table (135K rows), that...
more »

2017-06-18 21:06 (1) Answers

merge result of two joins

I have 3 tables: Book, Invoice, Download where the last two have foreign key to Book. I need to know number of successful invoices and downloads for each book. To get the result, I have 2 queries. The first one displays number invoices for each book:...
more »

2017-06-18 17:06 (2) Answers

Entity framework query not working using

My entity framework query is not returning any value. I wanted to replicate this query through entity framework: SELECT name FROM guitarBrands WHERE image = image. So I ended up trying this code below. public static string GetBrandByImage(string ima...
more »

2017-06-17 13:06 (2) Answers

Group By Largest revision string

I need to figure out a way to group these properly. I have a results set that returns Incident numbers which are actually datatype string, that have revisions done. I only need the grouping of the last revision number entered. Such as the below. IN...
more »

2017-06-17 00:06 (2) Answers

How get total amount in MS Access SQL?

I use following query to get OrderID : SELECT OrderItem.ID , ProductID , OrderID , Quantity , P.Title , P.CurrentPrice , P.ID , (P.CurrentPrice* OrderItem.Quantity) AS Total FROM OrderItem INNER JOIN Product AS P ...
more »

2017-06-16 21:06 (2) Answers

Am I vulnerable to an SQL injection?

I am making an SSRS report, with the stored procedure listed below. My users need a search tool that will return all possible results in the name field such that a name of 'AD' should return 'ADAM' and 'MADELYN'. I am worried that since I am using s...
more »

2017-06-16 19:06 (2) Answers

Need to verify inner join vs subquery

I have written an inner join equivalent of subquery. Could someone let me know if it is correct way of doing things and if it is more efficient way. Does the the ON keyword filter the same way as where clause Subquery select companyId, ...
more »

2017-06-15 13:06 (1) Answers

Better way to do a multi-join in this SQL Query?

I am trying to pull data from a table (a.table) to join to another table (b.table). For me to do that, I need to join a third table (c.table) to reference between tables Plan_Code and Policy_Riders. Please see the code below USE [CDS] GO SELECT rid...
more »

2017-06-14 20:06 (1) Answers