sql-server-2014

How to store longitude & latitude as a geography in sql server 2014?

一个人想着一个人 提交于 2019-11-30 11:37:00
I'm a sql beginner that knows how to get my users location in longitude and latitude coordinates. My goal is eventually to be able to select all rows from myTable Where distance is less than 2km. However on my way towards this goal there is some things that confuses me so I'll try to list what I'm failing to understand. How can i use the longitude and latitude to store location within a geography column?(because it's supposed to be only one geographic point not two right? not one for longitude and one for latitude?) Now that I've got the geography points, how can i select all the rows within a

Database project deploy fails in Visual Studio 2013

不羁的心 提交于 2019-11-30 10:53:08
I have a database project in a solution which will not deploy from Visual Studio 2013. It fails with an error message "Unable to connect to target server" . The same project, when opened in Visual Studio 2012 deploys without an issue. The database is Sql 2012 hosted in a Sql 2014 engine (express) The deployment settings are thus (with names changed to protect the innocent): <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <IncludeCompositeObjects>True</IncludeCompositeObjects> <TargetDatabaseName

Preventing deadlocks in SQL Server

瘦欲@ 提交于 2019-11-30 10:26:34
I have an application connected to a SQL Server 2014 database that combines several rows into one. There are no other connections to this database while the application is running. First, select a chunk of rows within a specific time span. This query uses a non-clustered seek (TIME column) merged with a clustered lookup. select ... from FOO where TIME >= @from and TIME < @to and ... Then, we process these rows in c# and write changes as a single update and multiple deletes, this happens many times per chunk. These also use non-clustered index seeks. begin tran update FOO set ... where NON

SQL Server Management Studio can not connect

十年热恋 提交于 2019-11-30 09:38:52
I have installed SQL Server Management Studio 2014. In "connect to server" window, I selected server type as "Database engine", server name as "(local)" but when I try to connect, n error is shown- TITLE: Connect to Server Cannot connect to .. ADDITIONAL INFORMATION: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL

Grouping and counting rows by value until it changes

寵の児 提交于 2019-11-30 09:38:01
I have a table where messages are stored as they happen. Usually there is a message 'A' and sometimes the A's are separated by a single message 'B'. Now I want to group the values so I'm able to analyze them, for example finding longest 'A'-streak or distribution of 'A'-streaks. I already tried a COUNT-OVER query but that keeps on counting for each message. SELECT message, COUNT(*) OVER (ORDER BY Timestamp RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) This is my example data: Timestamp Message 20150329 00:00 A 20150329 00:01 A 20150329 00:02 B 20150329 00:03 A 20150329 00:04 A 20150329 00

Does the Poor Mans T-SQL formatting add-in for Management Studio 2012 work in Management Studio 2014?

 ̄綄美尐妖づ 提交于 2019-11-29 19:50:23
Does the Poor Mans T-SQL formatting add-in for Management Studio 2012 work in Management Studio 2014? In SSMS 2012, if I go to tools, it showed up in the list. In SSMS 2014, it doesn't. I tried to run the installer again, and it gave me options to repair or uninstall. I had the formatter installed prior to installing 2014. EDIT: The tool is available here. alialtansaka Create the folder %SystemDrive%\ProgramData\Microsoft\SQL Server Management Studio\12.0\Addins\ if it does not exist. Then just copy the file from: %SystemDrive%\ProgramData\Microsoft\SQL Server Management Studio\11.0\Addins

Insert and update in a cursor in SQL Server

心已入冬 提交于 2019-11-29 18:01:36
I have a Table shown below DateRange 10/1 11/1 12/1 I am looping through this table using cursor and trying to populate a temp table Create table #BidStatusCalculation1 ( Code nvarchar(max), Data int ) Declare @monthStart varchar(20) DECLARE cur CURSOR FOR SELECT DateRange FROM @dateRange OPEN cur FETCH NEXT FROM cur INTO @monthStart WHILE @@FETCH_STATUS = 0 BEGIN Insert into #BidStatusCalculation1 select 'SL Payroll',Count(*) from DashboardData where DataType = 'Bid' and CONVERT(NVARCHAR, CreatedDate, 105) = convert(datetime, (@monthStart+'/'+@RequestYear)) FETCH NEXT FROM cur INTO

Database project deploy fails in Visual Studio 2013

橙三吉。 提交于 2019-11-29 16:06:46
问题 I have a database project in a solution which will not deploy from Visual Studio 2013. It fails with an error message "Unable to connect to target server" . The same project, when opened in Visual Studio 2012 deploys without an issue. The database is Sql 2012 hosted in a Sql 2014 engine (express) The deployment settings are thus (with names changed to protect the innocent): <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer

Preventing deadlocks in SQL Server

℡╲_俬逩灬. 提交于 2019-11-29 15:41:10
问题 I have an application connected to a SQL Server 2014 database that combines several rows into one. There are no other connections to this database while the application is running. First, select a chunk of rows within a specific time span. This query uses a non-clustered seek (TIME column) merged with a clustered lookup. select ... from FOO where TIME >= @from and TIME < @to and ... Then, we process these rows in c# and write changes as a single update and multiple deletes, this happens many

Changing sql-server DB from tabular to multidimensional

為{幸葍}努か 提交于 2019-11-29 14:35:36
I have following problem: When I try to deploy my SSAS project (with cube, dimensions and all that jazz) to sql-server, it throws error saying that You cannot deploy the model because the DB deployment server is not running in multidimensional mode. I'm new to this, so it might be a dumb question, but how do I change database mode from tabular to multidimensional? Tabular and Multi Dimensional are completely different thing. When you install SQL Server, you have to choose which one you are going to install. So, if you create a Tabular model, you only can deploy it to Tabular installation of