Query table with all names in one statement

I have a table that I cannot alter and I am trying to wrap my head around an appropriate way to query this table in one statement based on one given value. Roughly here's what the table looks like: What I'm after is a way to query the table using...
more »

2017-08-11 21:08 (3) Answers

SQL Server : populate table with dates

I am using SQL Server. I have a bit of a challenging problem (at least for me!). I have a table with information about TV Shows; the first column is the show's Title, the second is Genre, third is Language, the fourth column is the premiere date of...
more »

2017-08-11 18:08 (3) Answers

SSIS Argument SQL for option Copy is not valid

I am trying to do a SSIS package deployment to SQL server 2008. I generated the manifest file but double clicking it didn't open the deployment wizard. I have tried to execute the dtutil command from the command prompt but getting an error Argument ...
more »

2017-08-11 18:08 (3) Answers

C# & SQL Server : execute stored procedure

I have a SQL query inside a stored procedure and I get an error. Here is the query: IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fPartnersDebt]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) DROP FUNCTION [dbo]...
more »

2017-08-10 13:08 (1) Answers

Change Access database code to T-SQL code

I need to change MS Access database code to T-SQL code. Here is the SQL in MS Access: SELECT Max("SPR-" & Val(Replace([RequestID],"SPR-",""))+1) AS AutoID FROM Tb_Request Do you have any idea how to change this? Any comments would be greatl...
more »

2017-08-10 12:08 (1) Answers

Creating unique primary key to ignore duplicates

I have a main large table which I have had to put into 3rd normal form and into smaller tables (with primary and foreign keys linking them). The table is about renting books. I have a customer table which I need to create a primary key for. In the m...
more »

2017-08-09 22:08 (1) Answers

SQL Group by Client Location

Sample of Data I am trying to manipulate Order | OrderDate | ClientName| ClientAddress | City | State| Zip | -------|-----------|-----------|---------------|--------|------|-------| CO101 | 1/5/2015 | Client ABC| 101 Park Drive| Boston | MA ...
more »

2017-08-09 21:08 (1) Answers

Dynamic "column" in select with cast

I am looking for a way to cast data within a table based on a condition from another SQL query. My tables are as follows; DataTable: Id | EntityId | Value1 | Value2 | Value 3 ... Value200 Entity: Id | Name Fields: Id | EntityId | DataType | Fiel...
more »

2017-08-09 19:08 (1) Answers

create an classification for months ordered

I'm trying to create an column in my query to show an ordered classification ( show 1, 2, 3 ( as in first, second, third ...)) relative to date... in my current query i have filtered data from the last 12 months ( as example, from 1-9-2016 to 31-8-20...
more »

2017-08-09 16:08 (1) Answers

Microsoft.SqlServer.Types in ASP NET Core

I'm trying to get the nuget package Microsoft.SqlServer.Types to work in ASP Core targeting full framework 461. I need to use the types SqlGeography and SqlHierarchyId. But when I run my test I get following error 'Unable to load DLL SqlServerSpatial...
more »

2017-08-08 10:08 (0) Answers

Split SQL query into a nested query (subquery)

I am having difficulty converting the following into a sql statement with a subquery: SELECT "AM-Martin".dbo.CpCore_Site.Number , "AM-Martin".dbo.CpCore_Site.Latitude , "AM-Martin".dbo.CpCore_Site.Longitude , "AM-Martin".dbo.CpSm_Fa...
more »

2017-08-08 07:08 (1) Answers

Why is using Table Spool slower than not?

There are two similiar sqls running in sql server,in which the table TBSFA_DAT_CUST has millons rows and no constraint(no index and primary key), the other two has just a few rows and normal primary key: s for slower one: SELECT A.CUST_ID, C.CUST_N...
more »

2017-08-07 17:08 (0) Answers

Query slows down if a unused join is removed

I have a run into a "problem" which I cannot figure out how to solve. I have a query that runs in about 15 seconds, when I then add a join (which is not used in the select), the query actually speeds up to about 4 seconds, even thou nothing from the ...
more »

2017-08-07 16:08 (3) Answers