sql-server-2012

Sql Developer connector to Sql Server 2012 - error “Vendor code 207”

安稳与你 提交于 2019-12-07 01:58:38
问题 I am trying to connect from Sql Develper 4.0.3.16 to Sql Server 2012, with jTDS connector jtds-1.3.1.jar. OS: Ubuntu 14.04 Java: ~$ java -version java version "1.7.0_72" Java(TM) SE Runtime Environment (build 1.7.0_72-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode) In the create connection window, when I test the connection it is successful. When I open the connection I can see all the databases. When I try to open a database that I am supposed to have a permission to

Count, order desc and select top 5

只愿长相守 提交于 2019-12-07 01:45:16
问题 SQL Server 2012 We have a table, like such: ticket, type ------------------ 1234, hardware 1543, software 8859, network 5832, hardware 4900, hardware 8403, software 7859, network 4332, telephone 8721, database Our goal is to count up all tickets belonging to each type (so in this case the result should be 3 hardware, 2 software, 2 network, 1 telephone and 1 database ticket(s)), order them desc and select the first 5 resulting rows. We're trying to determine the top 5 "popular" or most seen

Get All Dates of Given Month and Year in SQL Server

末鹿安然 提交于 2019-12-07 01:37:12
问题 I want to get all dates by declaring month and year in SQL server. Can anyone please share easy lines of SQL code to get it. For example: DECLARE @month AS INT = 5 DECLARE @Year AS INT = 2016 SELECT * from Something I have tried below things, DECLARE @month TINYINT=5 ;WITH CTE_Days AS ( SELECT DATEADD( MONTH, @month, DATEADD( MONTH, -MONTH(GETDATE()), DATEADD( DAY, -DAY(GETDATE()) + 1, CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME) ) ) ) Dates UNION ALL SELECT DATEADD(DAY, 1, Dates) FROM

SqlRoleProvider: NullReferenceException when calling Roles.GetRolesForUser

夙愿已清 提交于 2019-12-07 01:03:21
问题 Scenario: WCF Service using SqlRoleProvider for authentication with a Sql Server 2012 Database server. WCF is hosted on a IIS7 webserver. please see this error: System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Security.Roles.GetRolesForUser(String username) RoleManagement is enabled. On my local development machine (server 2012, iis7) this works fine. When I log in and call the method the roles are retrieved. On the other server (test

Subtract hours from SQL Server 2012 query result

岁酱吖の 提交于 2019-12-06 23:51:56
问题 I am running queries on an alarm system signal automation platform database in SQL Server 2012 Management Studio, and I am running into some hiccups. My queries run just fine, but I am unable to refine my results to the level that I would like. I am selecting some columns that are formatted as DATETIME , and I simply want to take the value in the column and subtract 4 hours from it (i.e., from GMT to EST) and then output that value into the query results. All of the documentation I can find

Connection string for SQL Server Express on remote Computer login failed error

拥有回忆 提交于 2019-12-06 20:48:25
I recently asked the question at this address: Remote SQL Server connection string That thread has helped us arrive at this connection string: SqlConnection connection= new SqlConnection("Server=2.221.1.145;Database=Database;User Id=Andy-PC\\Andy;Password=mypass"); This throws the error: Login failed for user 'Andy-PC\Andy' This user owns the database and i guess should have access to it....however I remember when trying this style of authentication locally it did not work - which is why I originally started with Integrated Security=true. Is there something specific I need to do to add this

Add datetime and time

孤街浪徒 提交于 2019-12-06 20:46:09
问题 Server: SQL Server 2012; SP1; Developer Edition Code: declare @datetime datetime = '1900-01-01 00:00:00.000' declare @time time = '11:11:11' select @datetime + @time When I run the above code in the MASTER database, I get the error: Msg 402, Level 16, State 1, Line 3 The data types datetime and time are incompatible in the add operator. But when it's any other database, it works! Any idea why this must be happening? P.S. - In the enterprise edition, this throws an error irrespective of the

SQL Server Query: Using JOIN to include NULL values

人盡茶涼 提交于 2019-12-06 20:21:05
问题 I need help with the following SQL Server query where the columns a.TAProfileID and c.CountryCode have "NULL" values in the database. I want my JOIN statements to return "NULL" values where they exist. SELECT a.ReservationStayID AS 'Reservation Id', a.PMSConfirmationNumber as 'PMS No', a.CreatedOn AS 'Date Created', a.ArrivalDate AS 'Date of Arrival', a.DepartureDate AS 'Date of Departure', a.TAProfileID AS 'TA Id', a.StatusCode AS 'Status', b.PropertyCode AS 'Hotel', c.Name AS 'Travel Agency

Using STCrosses() with a Spatial Index in SQL Server

醉酒当歌 提交于 2019-12-06 20:16:35
Does The Microsoft StCrosses() function for Geography data support Spatial Index? When I try to execute this function with Spatial Index I get this error message: "The query processor could not produce a query plan for a query with a spatial index hint. Reason: Spatial indexes do not support the method name supplied in the predicate. Try removing the index hints or removing SET FORCEPLAN" No. Indexing spatial data is nontrivial, and the class you are discussing can contain arbitrarily complex figures, not just simple geometric shapes. The specific way shapes and indexing is implemented can

Decimal out of range

北慕城南 提交于 2019-12-06 19:59:38
问题 I'm trying to store the decimal 140.2705893427 into a SQL Server 2012 table. The column has a data type of decimal(12, 10) but I get the error: {"Parameter value '140.2705893427' is out of range."} Why is this? 回答1: decimal(12, 10) means 12 total digits, 10 of which may be after the decimal point. Your value of 140.2705893427 has 13 total digits, thus it is out of range. Read decimal and numeric (Transact-SQL) for documentation. 来源: https://stackoverflow.com/questions/18874410/decimal-out-of