Unable to Run Update Query in SQL Azure *Invalid object name 'DataSync.provision_marker_dss'.* - sql

I was syncing my Azure SQL Database with On-Premises SQL Database which created a lot of tables in the Online database (As Usual). Anyway, It was working fine.
Now, I had to re-create the Azure SQL Database. So, I deleted the Sync Group & Sync Agent as well.
Everything's working absolutely fine unless I run an Update Query on that database.
Whenever I run Update Query on some of the tables, the database shows the following error.
Msg 208, Level 16, State 1, Procedure finstock06_dss_update_trigger,
Line 9 Invalid object name 'DataSync.provision_marker_dss'.
There is no such table I ever created on the database.But it's name shows that it was one of the automatically created tables while syncing. (But why here? I have re-created the database)
Although, I created all the tables again on new database but facing this issue.
Any help would be appreciated.
Thanks

I had no sync groups left, and deleted all DataSync tables, but still got the error.
Triggers had to be deleted manually too:
https://richardjgreen.net/repairing-damaged-sql-azure-sync-group/

Related

Updating multiple tables data from different databases having same column name

I have 11 databases in which I'm having tables contains User Details i.e. all employee details. There I have a column "Status"(which is 1 for Active and 0 for Inactive). I have a regular tasks for updating "Status" column value 0 or 1 for mentioned employees and for that, I have to go through all the databases then User table then I have to update. The same task i have to do for all the database and it consumes a lot of time.
If I will get a short Query or Procedure that I have to run once and will do all updation at once then, it would be a great help.
I see a couple of possible options.
You could build an SSIS package to connect to each database and do the necessary updates provided the criteria of which employees to update and what to update them to could be found within the database or some external source such as a text file.
Alternatively, you could use SQLCMD mode in SQL Server Management Studio and then within your SQL script use CONNECT command to switch to each server and database something like this...
:CONNECT Server1
USE Database1
--put your update SQL script
:CONNECT Server2
USE Database2
--put your update SQL script
...
These links provide some further information on using SQLCMD mode...
Connecting to multiple servers in a Query Window using SQLCMD
SQL Server SQLCMD Basics
Noel
As you mentioned, you have 11 databases.
Problem : First, you are using very bad approach for database design,
What really Happens : When you are using multiple databases and you need to check in every database, then the server needs to connect to different database again and again, which takes very more time compared to switching into the tables, because of connection handling.
Solution : In your case, you have only one option to connect different databases in loops and then run the query in the loop for every DB.
Suggestion : you should keep all the data in the same database, you can use an extra column in tables to keep track your data to different entities.

Find what application is connected with what login to what database what table and what columns

Is there a Script which finds the current activity
from application->login->Database->Table->Column level ?
I have used
SP_who2, sp_who2'Active',Sysprocesses
Activity Monitor
Audit
Profiler
Trigger
Extended Events
and coludnt get column level data connections, i was able to get the sql statements, table name, database,instance, application, login name ...but I couldn't get Column Names
the reason I am trying to find to track all usage and re architect the Database..
any help is appreciated
SP_who2 and sp_who are the ones I have even used to get the required information. You can as well check against sys.sysprocesses to know about processes that are running on an instance of SQL Server.
If you want the columns involved in the queries then consider using SQL Server Tracing probably.

Azure SQL "select" query not showing all rows

I just used the SQLAzureMW (SQL Azure Migration Wizard Tool) to migrate my SQL Server database to Azure SQL. It went off without a hitch - all my tables are there, the website is running fine off it, etc.
Here's what's odd: if I execute a simple SELECT statement against my tables, I get only a few of the rows. I assumed they were missing, but my website is using some of those records as if they're there. So I queried with a WHERE clause and BAM - they showed up. How the... what the... why isn't my select showing me everything? This applies to many of the tables I've tested.
SQL Azure
On-Premise
I gave up on MS SQL Management Studio and am instead using SQL Server Object Explorer from Visual Studio 2012/2013. It functions properly and allows inline editing of data.
Consider this SELECT statement:
SELECT
SvcTimeID,
LoginName,
MeanSeconds,
MedianSeconds,
RequestCount,
StdDevSeconds,
SvcDate,
CAST (TS AS INT) AS TS
FROM dbo.SvcTime
WHERE SvcDate >= #SvcDate
Where the parameter is set:
cmd.Parameters["#SvcDate"].Value = DateTime.UtcNow - new TimeSpan(31, 0, 0, 0);
Execute that statement in an Azure Web Role - brought back, say 24 rows.
Now, insert two new rows; wait at least one minute; execute the statement again. Do the recently inserted rows appear? In my case, they did not. Note: the default value of SvcDate in the database is getutcdate().
Move the SQL Azure database from the web edition to the standard (S2) edition. Rows magically appear.
Here is my theory. The issue you had was not with MS SQL Management Studio but with SQL Azure itself where, under certain circumstances, the same query will return the original rows from a cache someplace and will miss the new rows in the database.
This has blown any remaining confidence I had with Azure.
I was scared at first, but I think this has an explanation:
If you inserted some rows in connection "A" and can't find them in other sessions, maybe you have a uncommited transaction. By default, in SQL Server on premise, your second connections would hung until transaction is commited or rolled back. (Isolation level read committed)
Somehow, using the same isolation level, Azure acts differently. I seems to work in some cases as a snapshot isolation. Because of that, you can read from the table, but results are not updated. Or maybe the lock are set in a different way.
To solve this, check sysprocesses for sessions with open_tran > 0 or just be careful commmiting trans. In the example, running commit in your session "A" should do it.
Good luck!

Syntax error when trying to change schema in SQL Server database

I am trying to rename the schema for a dozen tables in an old database on SQL Server 2005. I'm using SQL Server Management Studio Express version 9.0. Based on detailed advice found here, as well as several forums on other sites, I've been trying this straightforward command:
ALTER SCHEMA newschemaname TRANSFER oldschemaname.table1
I consistently get this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'SCHEMA'
It's the same whether I run it directly in the "New Query" window or build it into a stored procedure.
The database's owner is "SA," dating back to when my web host (the physical server's owner) first set up this database years ago. This makes me think there might be a permissions issue, or some obscure mismatch between the owner name and the login I'm using. But if that was true, I'd expect the error to tell me I don't have rights to execute that command.
Is there some obvious syntax error I'm missing, or do I need to delve deeper into the ownership and permissions to get the rights to fix this?
New Schema name needs to be in brackets otherwise it will fail
Example statement:
ALTER SCHEMA [NewSchemaName] TRANSFER dbo.Tracking

Using 2 differecnt DB's in same SP in SQL Azure

I am using an SP which will insert data in 2 tables in 2 different DB's. To mainitain the transaction, the SP has been designed like that. Its working fine in SQL Server environment.
Like Insert into AdminDB.EmpSiteConfig values(,,,)
Insert into MainDB.EmpDetails values(,,,)
where AdminDB and MainDB are the database names.
But when I migrate it to SQL Azure, I am getting an error as follows.
'Reference to database and/or server name in MainDB.dbo.EmpDetails' is not supported in this version of SQL Server.'
Can somebody tell me how to get rid of this error? Or is there any workaround for this?
Thanks in advance.
SQL Azure does not currently support linking to another server. As to workarounds, you could create a queue message requesting a specific action for data insertion. In your worker role, consume the queue message and call a separate stored procedure on each database.
although i think it is better to use David Makogon's solution you might want to take your changes with SQL Shard: http://enzosqlshard.codeplex.com/