sql-server-2012

Date Conversion Issue MS Access to SQL Server

本小妞迷上赌 提交于 2019-12-13 07:35:32
问题 I'm creating a table B from an exisitng table A. In the table A I have a column ValDate which is varchar and contains Date. When I try to create the table B I have a function used in the query as given below and I get a conversion error. Table A contains null values as well. MS Access: ((DateDiff("d",Date(),format(Replace(Replace([Table A].ValDate,".","/"),"00/00/0000","00:00:00"),"dd/mm/yyyy")))>0)). Tables were in MS Access and are being migrated to SQL Server 2012. SQL Server: ((DATEDIFF

Apply a substracton for each month

穿精又带淫゛_ 提交于 2019-12-13 07:24:17
问题 I have a Wonderware Historian server that captures data. I have to query it with SQL to find difference between the last value of a month and the first value of a month (the value is constantly growing). To select my data, I did this : SELECT Annees=YEAR(DateTime),Mois=MONTH(DateTime),Value=() FROM AnalogHistory where TagName = 'OBJECT_TAG_NAME' AND DateTime >= '01/01/2016 00:00:00' AND DateTime <= '24/07/2017 13:53:31'; I supposed I will need to use group and order by , but for now, I'm

Deploy RDLs from VS2013 to Sql 2008 ReportServer?

浪子不回头ぞ 提交于 2019-12-13 07:21:36
问题 I have an SSRS project that was created in VS2008 with several reports. These reports are deployed to ReportServer for Sql Server 2008` in a remote server. After receiving the VS2013 compatibility warning in my workstation, I successfully opened the SSRS project in VS2013 and opened an RDL. With that said, let's say I modify the RDL, what are my options to deploy this new report to the ReportServer in Sql Server 2008`? I also have the SQL Server 2012 MSDN media. Would updating SQL 2008 to SQL

Sequential(Gapless) Invoice Number Creation

∥☆過路亽.° 提交于 2019-12-13 07:14:38
问题 We have implemented a webapplication for Billing system.I have a string column to store invoice number. This column has to forbid gap between number. Id InvoiceNumber(Desired) InvoiceNumber(Actual) 1 001 001 2 002 002 3 003 005 In pseudo-code using (TransactionScope _ts = new TransactionScope()) { var _lastGeneratedRecDetails = _db.StudentReceipts .Where(r => r.Status == true && r.StudentRegistration.StudentWalkInn.CenterCode.Id == _centreCodeId && EntityFunctions.TruncateTime(r.DueDate.Value

Incorrect syntax near '<'

房东的猫 提交于 2019-12-13 06:48:57
问题 I have a task to get some code which is working correctly on SQL Server 2012 to work on SQL Server 2008 R2 as well. I got this error: Additional information: Incorrect syntax near '<' When I try to run my code I found out that something is wrong in this line of my SQL code ALTER TABLE [dbo].[WorkTimeEntries] ADD [TimeFinishedForRuntime] AS ISNULL([TimeFinished], IIF ([TimeStarted] < SYSUTCDATETIME(), [dbo].[udf_GetCurrentDateTimeOffsetInTimeZone](DATENAME(TZOFFSET, [TimeStarted])),

SQL Server foreign key conflict in a multi values statement?

十年热恋 提交于 2019-12-13 06:39:57
问题 I have a SQL Server INSERT sentence like below: insert into foo( num, a, b ) values (1, a, b), (2, a, b), ... (9999, a, b); But there is a "INSERT statement conflicted with the FOREIGN KEY constraint" error. The problem is that SQL Server does not tell me which exactly is the value or line with the problem. How can I quickly find what the value with the error? 回答1: You can turn this into a SELECT statement to find the rows that do not match. Assuming that the column a references the table

SQL Server 2012 Performance Issue

隐身守侯 提交于 2019-12-13 06:39:21
问题 we have a performance issue with our SQL Server 2012 Enterprise setup that I am unable to explain and I am hoping you guys have an idea. We have a fact table with a bunch of int columns that we aggregate as well as a region dimension table. This is the structure of our fact table: regionId (int) revenue (Decimal 10,2) orderIntake (Decimal 10,2) And this is the structure of our dimension table: worldRegion(varchar(100)9 cluster (varchar(100)) country (varchar(100)) regionId (int) The fact

LEAD/LAG SQL Server 2012/Gaps and Islands

一世执手 提交于 2019-12-13 06:06:55
问题 I'm having a few issues with LEAD/LAG. For each row within a set of IDs I'm wanting to get the previous/next source where isAQI = 1. Desired output is as follows in prevAQI and nextAQI columns. I've tried the same approach as Lag() with conditon in sql server, but with no luck. Any help would be much appreciated! Sample data as follows: DECLARE @a TABLE ( id int, timest datetime, source char(2), isAQI int, prevAQI char(2), nextAQI char(2)) INSERT @a VALUES (6694 ,'2015-06-11 08:55:06.000' ,'I

OrmLite With Filestream

爷,独闯天下 提交于 2019-12-13 06:04:51
问题 I did some searching and I could not find very much on utilizing filestream with OrmLite. I think it is possible but I am not sure which direction to take. Ideally I would like to be able to create or drop/create a table based on a model with a binary field and then do something to make that column in the database mapped to the filestream. I know that the filestream has to be setup on sql server ahead of time (I don't think you can do ALL the filestream setup from outside of the Management

How to renumber rows by groups

岁酱吖の 提交于 2019-12-13 05:46:53
问题 I need to renumber rows by group ( Class, Color, Type ) sequences in column SeqNo from: Class | Color | Type | SeqNo Animal | Brown | Terr | 1 Animal | Brown | Aqua | 3 Animal | White | Terr | 3 Plant | Green | Aqua | 2 Plant | Green | Aqua | 2 Plant | Green | Aqua | 2 Platn | Green | Terr | 9 to: Class | Color | Type | SeqNo Animal | Brown | Terr | 1 Animal | Brown | Aqua | 2 Animal | White | Terr | 1 Plant | Green | Aqua | 1 Plant | Green | Aqua | 1 Plant | Green | Aqua | 1 Plant | Green |