SQL Merge Replication ignores filter - sql-server

I have a merge replication (SQL 2005) with a filter.
The filter is on table delLog and says WHERE 0 = 1, so all the data is only uploaded, not downloaded.
When I want to download my data, and it comes to this table it says downloading table delLog and hangs there for an hour...
I get no errors for this it just hangs there...
any ideas how to solve this problem?

Related

ADF Copy Activity Not copying all data

Here is my scenario.
I am using a simple copy activity in ADF to move data from one SQL Server to another.
I mainly do a full load to start off and then write a SQL Query to fetch data from last 3 hours. Followed by a trigger run each hour.
My data pipeline works like this:
Source -> Azure Table storage -> Azure SQL.
Problem is happening from source to Table.
It is working fine for all other tables except one.
For that particular table it is only copying 1 row. Unless I go back in and do a full load thats when I get all the data.
Can someone please help me understand what is going on.
Please ask for clarification and more details if needed.
You are facing this issue because of following reason
• Primary key violation when writing to SQL Server/Azure SQL Database/Azure Cosmos DB.
For example: Copy data from a SQL server to a SQL database. A primary key is defined in the sink SQL database, but no such primary key is defined in the source SQL server. The duplicated rows that exist in the source cannot be copied to the sink. Copy activity copies only the first row of the source data into the sink. The subsequent source rows that contain the duplicated primary key value are detected as incompatible and are skipped.
Refer - https://learn.microsoft.com/en-us/azure/data-factory/copy-activity-fault-tolerance#supported-scenarios

MsSql - select didnt return values for all columns properly

i would like to ask maybe basic question. My SSIS uses SQL query, result is exported to *.csv file. Everything works fine for months (sql select, sql records/results are in csv export) - but yesterday i have issue: SSIS ran without error, but in *.csv export one column was without any records(column header is in csv file, but records not) - in another columns there were records (records are from same table as missing column:(). when i ran SSIS manually again (cca 4 min after), data were in column. SSIS is deployed and run on same sever as database. my question is - if there is no error in SSIS Execution report, data flow task ran correctly, now query returns all data withou editing .... is there any chance to find what caused data loss? maybe on server log?
thank you

Automate sql server profiler to record data then save data to a table continuously

Is there a way to automate sql server profiler to record data then save data to a table continuously?
The reason, I am supporting a fragile SQL Server application and there is no auditing. I receive a lot of support calls regarding the deletion of records. I want a quick way to be able to view who has changed what data.
You can configure your profiler to save the trace directly to table as described here: How To Save a SQL Server Trace Data to a Table
But it's not a good idea for 2 reasons: first, profiler itself will be loading up your server, second, writing to table is the most costly option and you can even loose some events.
Maybe if you are on Enterprise edition you can use SQL Server database audit
that is more light weight
And here you can find a complete example of setting up database audit that audits the DELETE events
Here are few articles for your reference.
Save trace results to a database table
https://learn.microsoft.com/en-us/sql/tools/sql-server-profiler/save-trace-results-to-a-table-sql-server-profiler
Save Trace Results to a Table
https://technet.microsoft.com/en-us/library/ms191276(v=sql.110).aspx
9 Steps to an Automated Trace
http://sqlmag.com/t-sql/9-steps-automated-trace
alternatively, you may try this automated solution ( https://www.lepide.com/lepideauditor/sql-server-auditing.html ) to accomplish this task.

Table searches fast on local SQL Server but slow on host SQL Server

I have a SQL Server 2008 database with a table that contains about a 100,000 rows, I have setup all the correct indexes and primary keys and Full Text Search and made sure its fine tuned.
I created a stored procedure that searches a nvarchar column in the table, the SP is long and has multiple select / insert statements.
Now when I run the SP on my local SQL Server I get the result in one second, then I backed up the database and restored it on another machine and tried the same search and I got it in one second.
My problem is when I create the database in my hosts shared SQL Server and import all the data from my SQL Server and run the search I get the result in 7 seconds! although I made sure I have the same indexes and primary keys and FTS working.
The only difference in my database in the hosts sql server is that I created the schema using a script then I imported all the data using the import/export wizard, so to check if this is whats causing this problem I created a new database on my machine and imported the data using the wizard, and I got the search result in 3 seconds!
I checked the execution plan of the SP in the database on the hosts SQL Server and found one index scan is taking 49% of the cost while on my machine it was 0%
Can somebody please point out why this is happening?
Thanks.
EDIT:
Now when I run the execution plan for both servers I get exactly the same plan and costs, but still the speed difference is huge (1 second and 7 seconds).
Although I didn't solve the strange behavior in SQL Server, I ended up replacing this stored procedure with Full Text Search and it gave a faster result.

String or Binary DAta would be truncated on Delete

I'm trying to delete a couple of rows
USING
SQL Server management studio, for 2 rows only i get the message
No rows were deleted
A problem occurred attempting to delete row #X
Error Source: .Net SqlClient Data Provider
Error Message: String or binary data would be truncated
The Statement has been terminated
Correct the errors and attempt to delete the row again or press ESC to cancel the change(s)
What could be happening while deleting the row ?
the keys are unique so that's not an issue
I've deleted the rows using manual DELETE statements but curious about what's going on here
any thoughts ?
this is using SQL 2008 R2 Express edition
UPDATE - there are no triggers on the table
Try running SQL Profiler while deleting through SSMS if you want to know exactly how it's deleting them.
Do you have a delete trigger on the table? It could be that one of the variables that you're logging into an audit table is longer when going through the GUI instead of through the query window.
In any event, providing the table definition and the rows being deleted might help others find a solution to your question.

Resources