sql-server-2012

Slow merge replication over a WAN link - only downloads

北战南征 提交于 2020-01-26 04:09:25
问题 We've been using SQL Server merge replication for a few years to synchronise data between our data centres, but we are now suffering with a big performance issue. This may be because the amount of data we are synchronising has increased a lot this year. Our publisher is an always-on data centre in the UK. Our subscriber is a mobile data centre that travels around the world and is on for periods of up to a week at a time, approx. 25 times a year. However, it also spends the same amount of time

Using SQL Merge or UPDATE / INSERT

爷,独闯天下 提交于 2020-01-25 11:17:26
问题 I have a table (Customer_Master_File) that needs to updated from flat files dumped into a folder. I have an SSIS package that runs to pick up the flat files and imports them into a temp table (temp_Customer_Master_File) What I have been unable to do is this: for each record in the temp table, if the Customer_Number exists in the Master table, update it, if not insert the contents of the temp table. I'm updating all fields of the record, not looking for individual field changes. I tried the

Check if there's an existing record on the day before

让人想犯罪 __ 提交于 2020-01-25 06:48:25
问题 I'm trying to check if there's an existing record on the day before the selected schedule date. How do we do this? I tried using LAG() , but I'm having problem when it comes to sorting out the data because of the NULL . DATEDIFF() won't solve my problem as well because I need to check if there's an existing data on that date, and not -1 the date. What I want to query if example. Day before 2020-01-02 has recordin and recordout , it should reflect NULL if necessary. Is there a way to do this?

How to compare two given dates with date coming from datetime field in sql server

前提是你 提交于 2020-01-25 06:48:04
问题 I have got user entered Datetime fields like CreatedON and CreatedEND and these are having datetime formats like (29-02-2013) and (12-04-2013) (these are sample values only) I have got one column in sql server like CreatedDatetime and values like this 2013-09-03 and 2013-02-03 (these are sample values only) Now I need to check whether the CreatedDatetime field is in between CreatedON and CreatedEND two given dates... How can i compare the date coming from database with these two values.. this

how to change log_reuse_wait and log_reuse_wait_desc

老子叫甜甜 提交于 2020-01-25 01:59:53
问题 I have been created new database and the log file groth very past, and I get error mesaage that the log is full due to 'BACKUP'. I looked in the differences between this Database and other databases in the SERVER, and I seen that in all databases log_reuse_wait is 0 and log_reuse_wait_desc is NOTHING and in my database log_reuse_wait is 0 and log_reuse_wait_desc is LOG_BACKUP. I want to change this property in my database to 0 and NOTHING. How can I do that? 回答1: This is a read-only status

How to use XQuery to simulate STRING_AGG() (grouped string concatenation)?

牧云@^-^@ 提交于 2020-01-25 00:17:08
问题 I have XML data which I need to convert to relational form. I use XQuery cause I don't know the number of address nodes. I'd like to get the whole address/adresses separeted by a comma. I guess I need to use LET clause but I'm still receiving an error. Here's my code: declare @xml as xml = '<root> <Row> <proceeding> <signatures>V GU 86/18</signatures> <signatures>V GUp 9/19</signatures> <signatures>V GUp 8/19</signatures> </proceeding> <entity> <info> <cleaned_name>Kate Smith</cleaned_name> <

wrong is_identity in sys.columns for inline functions

此生再无相见时 提交于 2020-01-24 12:35:27
问题 I have a problem with sys.columns for inline functions. Maybe an error of SQL Server or I'm missing something? Let's start from beginning, I have a simple table and a simple function like these: DROP TABLE [dbo].[SimpleTable] GO CREATE TABLE [dbo].[SimpleTable]( [id] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED, [descr] [varchar](50) NULL ) GO DROP VIEW SimpleView GO CREATE VIEW SimpleView AS SELECT * FROM SimpleTable GO DROP FUNCTION SimpleFunction GO CREATE FUNCTION SimpleFunction(

T-SQL split on delimiter

家住魔仙堡 提交于 2020-01-24 04:25:52
问题 I am working with an employee hierarchy string that is in the format of the following. These number represent employeeID numbers and how the are structured within the company, thus being able to follow the chain of management. 123|456|789|012|345|320 I am trying to take this string of data and turn it into a temp table so I can work with each of the ID's as their own value. I tried making a function to split the string: ALTER FUNCTION [dbo].[SplitString] (@String NVARCHAR(4000), @Delimiter

Microsoft SQL Server , Error : 87

孤者浪人 提交于 2020-01-23 03:46:05
问题 I am really tired, it's been 3 days that I can't open my SQL Server Management Studio. I got connection string error with number 87. Below screenshot show my problem: And I use localhost\MSSQLSERVER with error 87 and Arash-PC (my machine name) with error number 2. And I tried sqlcmd -U sa -S Arash-PC too 回答1: You need to check in your SQL Server Configuration Manager what services and instances you have installed. Go to Start Menu > All Programs > Microsoft SQL Server (version) >

How do I capture the data passed in SqlBulkCopy using the Sql Profiler?

ε祈祈猫儿з 提交于 2020-01-22 11:59:38
问题 I am using Sql Profiler all the time to capture the SQL statements and rerun problematic ones. Very useful. However, some code uses the SqlBulkCopy API and I have no idea how to capture those. I see creation of temp tables, but nothing that populates them. Seems like SqlBulkCopy bypasses Sql Profiler or I do not capture the right events. 回答1: Capturing event info for bulk insert operations ( BCP.EXE , SqlBulkCopy , and I assume BULK INSERT , and OPENROWSET(BULK... ) is possible, but you won't