sql-server-2012

SQL Server Data Tools Ignores Refactor on Schema Compare

帅比萌擦擦* 提交于 2020-01-15 05:57:28
问题 I'm having a seemingly identical problem to what is described here: SSDT Refactor Rename is ignored by the Schema Comparison script generation. Essentially, the refactor component of SQL Server Data Tools is not working on schema comparison/update. Instead of renaming a table, for instance, the table with the old name is dropped and the table with the new name is created. Unfortunately, I do not see an accepted answer to that question. I found a similar question, which seems to be have been

Ignore null values when using SQL Server 2012's Last_Value() function

三世轮回 提交于 2020-01-14 18:54:35
问题 I am using SQL Server 2012 and have a table of values that look like this. It is populated with event data. FldType Date Price Size -------------------------------------------- 2 2012-08-22 00:02:01 9140 1048 0 2012-08-22 00:02:02 9140 77 1 2012-08-22 00:02:03 9150 281 2 2012-08-22 00:02:04 9140 1090 0 2012-08-22 00:02:05 9150 1 1 2012-08-22 00:02:06 9150 324 2 2012-08-22 00:02:07 9140 1063 I would like to track the lastest value for each of the 3 field types (0,1,2) so that the final output

Offset Fetch Next to get all rows

允我心安 提交于 2020-01-14 07:53:26
问题 I have a query in SQL Server 2012 that should get back a number of records based on the page size I specify and the page it is on. It looks like this: SELECT LocID, LocName FROM Locations ORDER BY LocName OFFSET @PageNum ROWS FETCH NEXT @PageSize ROWS ONLY The code is pretty simple. What I need to do, though, is put that into a function to return the paging correctly. However, I could also be needing all records back from this function, so I need to have the option of calling the function

Offset Fetch Next to get all rows

旧巷老猫 提交于 2020-01-14 07:53:08
问题 I have a query in SQL Server 2012 that should get back a number of records based on the page size I specify and the page it is on. It looks like this: SELECT LocID, LocName FROM Locations ORDER BY LocName OFFSET @PageNum ROWS FETCH NEXT @PageSize ROWS ONLY The code is pretty simple. What I need to do, though, is put that into a function to return the paging correctly. However, I could also be needing all records back from this function, so I need to have the option of calling the function

catastrophic failure trying to select from linked server

落爺英雄遲暮 提交于 2020-01-14 07:15:32
问题 I have created a linked oledb/odbc connection to Pervasive SQL from SQL SERVER 2012: USE [master] GO /****** Object: LinkedServer [KSLAP208] Script Date: 2/8/2013 10:38:55 AM ******/ EXEC master.dbo.sp_addlinkedserver @server = N'KSLAP208', @srvproduct=N'Pervasive ODBC Interface', @provider=N'MSDASQL', @datasrc=N'C003', @location=N'localhost' /* For security reasons the linked server remote logins password is changed with ######## */ EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'KSLAP208

Sql Server 2012 slower than 2005?

℡╲_俬逩灬. 提交于 2020-01-14 05:18:12
问题 We have deployed SQL Server 2012 Enterprise and we have performance issues: same data (backuped from our SQL Server 2005 Enterprise and restored on 2012) test script of 3200 sql SELECT statements We do tests using Management Studio: results as plain text results in a file On same computer: 2005 : 15 sec, 2012 : 2 min 2005 : 14 sec, 2012 : 30 sec Even with a more powerful computer, 2012 is still slower than 2005. What can be wrong? The way we installed SQL Server 2012 and default parameters?

Detecting file size before sp_send_dbmail

半世苍凉 提交于 2020-01-14 03:07:12
问题 We're using the following with a 10MB limit for attachments. EXEC msdb..sp_send_dbmail @recipients = 'me@me.co.uk', @subject = 'foo bar', @file_attachments = 'C:\xxx\yyy\myFile.xlsx, @body_format = 'html', @body = 'norf'; Is it possible in the SQL Server scripts to check the size of myFile.xlsx before running this script? 回答1: I have a solution by using Batch Files: [C:\FileSize.cmd] @echo %~z1 Now you can get size of <your_file> by using that file: DECLARE @t table(filesize int) INSERT INTO

Detecting file size before sp_send_dbmail

僤鯓⒐⒋嵵緔 提交于 2020-01-14 03:07:01
问题 We're using the following with a 10MB limit for attachments. EXEC msdb..sp_send_dbmail @recipients = 'me@me.co.uk', @subject = 'foo bar', @file_attachments = 'C:\xxx\yyy\myFile.xlsx, @body_format = 'html', @body = 'norf'; Is it possible in the SQL Server scripts to check the size of myFile.xlsx before running this script? 回答1: I have a solution by using Batch Files: [C:\FileSize.cmd] @echo %~z1 Now you can get size of <your_file> by using that file: DECLARE @t table(filesize int) INSERT INTO

Error when Update-Database using Code-First: “There is already an object named 'something' in the database.”

霸气de小男生 提交于 2020-01-14 02:30:53
问题 I'm doing database migration using Code-First in Visual Studio 2015. Along the way, i've done the migration steps up till Add-Migration . After Add-Migration, i've added this line of code Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of DbContext1, Migrations.Configuration)) in my DbContext constructor to set up Database Initializer since i missed this step previously. After that, i executed "Add-Migration initial -Force" in the Package Manager Console because i fear that this

Identify sub-set of records based on date and rules in SQL Server

巧了我就是萌 提交于 2020-01-13 17:57:09
问题 I have a dataset that looks like this: I need to identify the rows that have Linked set to 1 but ONLY where they are together when sorted by ToDate descending as in the picture. In other words I want to be able to identify these records ( EDITED ): This is a simplified dataset, in fact there will be many more records... The logic that defines whether a record is linked is if the FromDate of a record is within 8 weeks of the ToDate of the preceeding date...but this is testData so may not be