sql-server-2012

SQL Server 2012 : The version of SQL Server in use does not support datatype 'datetime2'

落花浮王杯 提交于 2020-01-16 05:41:50
问题 While executing a stored procedure created in SQL Server 2008 R2 in SQL Server 2012 and retrieving the data through an Entity Data Model, this error occurs: The version of SQL Server in use does not support datatype 'datetime2' The stored procedure is executing successfully in SQL Server Management Studio 2012. But the issue is when coming back to the Entity Data Model. Anyone encountered this kind of an issue?? 回答1: What is the compatibility level of that database you're running against?

Output dates in MMDDYYYY format efficiently

妖精的绣舞 提交于 2020-01-16 01:24:39
问题 I have the below script which results YYYYMMDD . However, I need the result in MMDDYYYY format. Can someone please assist? I want no dash/stroke/periods between the numbers. SELECT CONVERT(VARCHAR(10), RowUpdateDateTime, 112) from MyTable Results: 20141113 I want it to look like 11132014 . I tried the FORMAT syntax but it was taking forever to run. 回答1: Take a look at the CONVERT() documentation: none of formats match exactly what you're looking for. It looks like 110 is the closest. We can

Output dates in MMDDYYYY format efficiently

自古美人都是妖i 提交于 2020-01-16 01:24:08
问题 I have the below script which results YYYYMMDD . However, I need the result in MMDDYYYY format. Can someone please assist? I want no dash/stroke/periods between the numbers. SELECT CONVERT(VARCHAR(10), RowUpdateDateTime, 112) from MyTable Results: 20141113 I want it to look like 11132014 . I tried the FORMAT syntax but it was taking forever to run. 回答1: Take a look at the CONVERT() documentation: none of formats match exactly what you're looking for. It looks like 110 is the closest. We can

Multpilcation Aggregate in Sql Server

半城伤御伤魂 提交于 2020-01-16 00:54:09
问题 I am trying to create Multplication aggregate function from the below sql code. declare @Floats as table (id int,value float) insert into @Floats values (1,1) insert into @Floats values (2,3) insert into @Floats values (3,6) SELECT * FROM @Floats a CROSS apply (SELECT CASE WHEN MinVal = 0 THEN 0 WHEN Neg % 2 = 1 THEN -1 * Exp(ABSMult) ELSE Exp(ABSMult) END AS mul_value FROM (SELECT Sum(Log(Abs(NULLIF(Value, 0)))) AS ABSMult, Sum(Sign(CASE WHEN Value < 0 THEN 1 ELSE 0 END)) AS Neg, Min(Abs

T SQL Query Format to Build Dynamic Table

大兔子大兔子 提交于 2020-01-15 14:47:13
问题 I need help creating a query to generate the results I am looking for. I'm creating an application to track employee attendance based off an existing database table. The user selects a date or group of dates from a calendar (say 10/1/18 , 10/2/18 and 10/3/18 ). They click submit and I need to generate a table that displays every employee with a check mark in the date column if they were there that day. The table is called History and has 2 main columns: EmployeeID; and TransactionDate. Every

How do you get past this sort of error: “Ad hoc updates to system catalogs are not allowed.”?

雨燕双飞 提交于 2020-01-15 10:33:31
问题 Take the following input: update sys.assemblies set permission_set_desc = 'EXTERNAL_ACCESS' where assembly_id = <someInt> and name not like 'microsoft%' and the following output: Msg 259, Level 16, State 1, Line 2 Ad hoc updates to system catalogs are not allowed. This is in SQL Server 2012. I'm logged in as "sa", so this is probably not a user permissions issue. Links I'm finding on Google are either void of solutions or hard for me to follow. How do I get past this without producing

How do you get past this sort of error: “Ad hoc updates to system catalogs are not allowed.”?

老子叫甜甜 提交于 2020-01-15 10:31:59
问题 Take the following input: update sys.assemblies set permission_set_desc = 'EXTERNAL_ACCESS' where assembly_id = <someInt> and name not like 'microsoft%' and the following output: Msg 259, Level 16, State 1, Line 2 Ad hoc updates to system catalogs are not allowed. This is in SQL Server 2012. I'm logged in as "sa", so this is probably not a user permissions issue. Links I'm finding on Google are either void of solutions or hard for me to follow. How do I get past this without producing

How can i get the total of a rows dynamically generated columns in a select query

坚强是说给别人听的谎言 提交于 2020-01-15 09:33:25
问题 DECLARE @DynamicColumns VARCHAR(MAX) SET @DynamicColumns = '[Mon, Oct 31 2016], [Tue, Nov 1 2016], [Wed, Nov 2 2016], [Thu, Nov 3 2016],[Many More Columns Can be Added]' I have a temp table that has columns FirstName & LastName. The table will also contain dynamically generated columns depending on the parameters passed to the stored procedure. The dynamically added columns could be 10, 100 or 2. I can access the names of the generated column in the @DynamicColumns variable i have declared

Why are my buffered points oblong and not circle in SQL Server Management Studio - Spatial Results

无人久伴 提交于 2020-01-15 07:14:20
问题 When I apply STBuffer(1) to a Point in SQL Server Spatial, they show up as an oblong circle, instead of a perfect circle. Why is this? 回答1: The selected projection is Equirectangular , and not the more familiar Mercator that we see in Google Maps & Bing Maps. Change this and the points will show up as expected. More information about map projection here: http://en.wikipedia.org/wiki/Map_projection 来源: https://stackoverflow.com/questions/19693067/why-are-my-buffered-points-oblong-and-not

understanding how a primary key works & how to use it

假装没事ソ 提交于 2020-01-15 07:01:23
问题 I am using SQL Server and creating a table (example is at the very bottom of this question). However I am having some issues understanding how primary keys actually work & how to use them properly. So I know a primary key ensures all the rows in a table are unique and that a primary key can't be null. I also read this page index basics - simple talk on indices and how indices are organised in a b-tree structure. So in my table for a row to have a unique value I would have to use the first 3