sql-server-2008-r2

F# OleDb Syntax Error in INSERT INTO Statement Pulling Data from Access to Linked SQL Server

一个人想着一个人 提交于 2019-12-24 01:02:01
问题 I'm running an F# application to pull data from an Access table to a linked SQL Server table. Here is the resulting query: INSERT INTO dbo_TempTerm (UnitID, PolicyTermYear, InsuredName, PolicyNumber, RenewalDate, CovATotal, CovBTotal, CovLTotal, DwellExtn, AllOtherPerilDeductible, MedPay, TotalPremium, HurricaneDeductible, Zone, Subzone, PercentCRC, PercentCRD, YearBuilt, RenYrs, PercentCFD, PercentHA, PercentMLD, GRP1, PercentNH, QCLM, RateV, CRI, AgentCode, AgentName, AFOCode, PolicyType,

SQL Server, variable in IN Clause

不羁的心 提交于 2019-12-24 00:57:38
问题 I want to use a variable inside IN clause, similar to this: Declare @tt NVARCHAR(MAX) SET @tt = '02ea2b81-07f0-4660-bca1-81563f65bf65','07728975-cb1d-484c-8894-14f5b793cbef','1071ee4f-a214-443f-8694-0b3e9d2dc77e','120d2881-b04f-4707-a925-e4d941f03201','23af54a7-6666-4747-a74a-c2101cda59b0','260d2ce5-f4f0-4a0b-aa0b-3e1d2b5fcfeb','2710a913-13e7-4300-91f1-2646e2f8449e','2cebc482-4917-4aa3-973b-2481619a78e7','2d2269a4-9164-4dae-a732-90448d761509','2d29c707-1c5f-4e00-bd3c-bfd2ec2c6e29','3ead72a1

replace only matches the beginning of the string

回眸只為那壹抹淺笑 提交于 2019-12-24 00:55:57
问题 I'm trying to write a function to replace the Romanian diacritic letters ( ĂÂÎȘȚ ) to their Latin letter equivalents ( AAIST , respectively). SQL Server's replace function deals with Ă , Â , and Î just fine. It seems to have a weird problem with Ș and Ț , though: they are only replaced if they are found at the beginning of the string. For example: select replace(N'Ș', N'Ș', N'-') -- '-' # OK select replace(N'ȘA', N'Ș', N'-') -- '-A' # OK select replace(N'AȘ', N'Ș', N'-') -- 'AȘ' # WHAT??

T-SQL query group in date order (gaps and islands)

最后都变了- 提交于 2019-12-24 00:42:20
问题 I have a sample table like this: CREATE TABLE #Aggregate ( vKey INT ,dKey INT ,StartTrip DATETIME ,EndTrip DATETIME ,Distance INT ) with some sample data like so INSERT INTO #Aggregate (vKey, dKey, StartTrip, EndTrip, Distance ) VALUES (4940, 0, '2016-09-14 09:05:47.000', '2016-09-14 10:07:45.000', 25) ,(4940, 0, '2016-09-15 14:09:40.000', '2016-09-15 14:11:33.000', 35) ,(4940, 1202, '2016-09-16 17:07:04.000', '2016-09-16 18:07:04.000', 61) ,(4940, 0, '2016-09-26 16:43:03.000', '2016-09-26 16

SQL - calculate forecast average

给你一囗甜甜゛ 提交于 2019-12-23 23:26:23
问题 I'm trying to calculate a forecast of sales based on the 3 previous months which either can be actuals or forecast. company_id Year Month Actuals Forecast 123456 2014 1 10 123456 2014 2 15 123456 2014 3 17 123456 2014 4 14.00 123456 2014 5 15.33 123456 2014 6 15.44 123456 2014 7 14.93 Month 4 = (10+15+17)/3 Month 5 = (15+17+14)/3 Month 6 = (17+14+15.33)/3 Month 7 = (14+15.33+15.44)/3 Let's say I want to calculate the forecast for the next 18 months for each company. I'm looking at the data

getting error while creating new diagram in SQL Server 2008 R2/

不打扰是莪最后的温柔 提交于 2019-12-23 19:49:32
问题 I am getting this error when trying to create a new diagram in SQL Server 2008 R2: The specified module could not be found. (MS Visual Database Tools) Program Location: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at Microsoft.SqlServer.Management.UI.VSIntegration.NativeMethods.ThrowOnFailure(Int32 hr) at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType,

SQL Server , restrict UNPIVOT to order columns automatically

拟墨画扇 提交于 2019-12-23 19:46:51
问题 I have a table with data in one row: Account | OrderID | OrderName | Priority | Fasting |AssignedTo |ResultsTo |Location ---------------------------------------------------------------------------------------------------------------------------- 12345 | REQ123456 | Lipid Panel (1.2) |Routine | Yes |Fast, Brook |Nurse Group |Fisher Rd, Woodbridge, NV Now I want to UNPIVOT the data to show the user in the following form: GROUPCOL | LABEL | VALUE -------------------------------------------------

Force partial join order in SQL Server

 ̄綄美尐妖づ 提交于 2019-12-23 19:22:00
问题 Edit : People are having a hard time understanding what i want. So here's pretty pictures that explains it in excruciating detail. First join Transactions to Strange : The results so far Customer Invoice TransactionID Mass Length LeptonNumber ======== ======= ============= ==== ==================== ============ Ian One 1 Ian Judgement Spaulders 50 Ian One 1 Ian Glorious Breastplate 50 Chris Two 2 Chris Barenavel 2 Now attempt to join remaining rows with Down : The results so far Customer

SQL Server Default value for columns

拥有回忆 提交于 2019-12-23 18:13:49
问题 When you use default value for a column in SQL Server Management Studio table designer, SSMS change your default and stand Parenthesis around of that (In all editions and all versions of SQL Server). For example if you set 0 as default value, this default changed to (0) . I don't know why sql server use parenthesis, and is there a practical reason. Thanks in advance. 回答1: There are certain types of objects, such as DEFAULT s and CHECK constraints that SQL Server doesn't store the original,

How to handle TransactionInDoubtException

故事扮演 提交于 2019-12-23 17:22:58
问题 i have some simple SELECT statements and an INSERT wrapped in a using(TransactionScope...) block. UPDATE: isolation level is ReadCommited i got the following exception on calling scope.Complete() .(see below) At the same time the database was under high load caused by another application entirely. After the fact i found that the INSERT statement did in fact execute. My question is: How do i handle this exception in a way that leaves my database in a consistent state ? i`m looking for a