How to insert records to msdb.dbo.sysoperators - sql

How can I insert data to msdb.dbo.sysoperators.I got an permission error. Checked with dba(who has admin right) also getting same error. Is there any other work around I can try
Help is appreciated

Related

error message when trying to write a sequence

i am trying to write the following sequence
INSERT INTO cruise (cruise_id, cruise_name)
VALUES (SEQ_CRUISE_ID.NEXTVAL, 'hawaii and back');
but when I execute it, I receive an error message. I do have privileges to execute the command. I appreciate any help and suggestions on this one
Can you give us the error message so we can have more insight into the issue? The only issue found is that this db collection might not exist. Can you confirm if table in question exists?
table: cruise

Error when inserting data in ssms through "Execute Stored Procedure"

The below shown is my program:
As You can see, all the table details are correct. But when I try to run it through the "Execute Stored Procedure", the details are not entered into the table.
Rather I get a output like this:
How I can solve this?
Note: Recently had MSDB in SUSPECT, so, took my friends MSDB log and data, is that causing the problem? If yes, what can i do about that?
The error message would certainly help. A quick, easy change would be to replace
set #msg='Error'
with
set #msg= ERROR_MESSAGE();
so we can see the error.
If this isn't possible I suggest:
Run the INSERT statement manually to see what message you get
Check that the ID column is an Identity column as you don't provide the ID in the INSERT so I assume it should be
I hope this helps.

Table is automatically truncated on SQL Server

I have a really strange problem on my SQL Server.
Every night 2 tables, that I have recently created, are being automatically truncated...
I am quite sure, that it is truncate, as my ON DELETE Trigger does not log any delete transactions.
Additionally, using some logging procedures, I found out, that this happens between 01:50 and 01:52 at night. So I checked the scheduled Jobs on the server and did not find anything.
I have this problem only on our production server. That is why it is very critical. On the cloned test server everything works fine.
I have checked transaction log entries (fn_dblog), but didnt find any truncate logs there.
I would appreciate any help or hints that will help me to find out process/job/user who truncates the table.
Thanks
From personal experience of this, as a first step I would look to determine whether this is occurring due to a DROP statement or a TRUNCATE statement.
To provide a possible answer, using SSMS, right click the DB name in Object Explorer, mouse over Reports >> Standard Reports and click Schema Changes History.
This will open up a simple report with the object name and type columns. Find the name of the table(s), click the + sign to expand, and it will provide you history of what has happened at the object level for that table.
If you find the DROP statement in there, then at least you know what you are hunting for, likewise if there is no DROP statement, you are likely looking for a TRUNCATE.
Check with below query,
declare #var as varchar(max)='tblname'
EXEC sp_depends #objname =#var;
it will return number of stored procedure name which are using your table and try search for any truncate query if you have wrote by mistake.
Thanks a lot to everyone who has helped!
I've found out the reason of truncating. It was an external application.
So if you experience the same problem, my hint is to check your applications that could access the data.
I don't know if can help you to resolve the question.
I often encounter the following situations.
Look at this example:
declare #t varchar(5)
set #t='123456'
select #t as output
output:12345

How to Truncate table in DB2? Error: Not a valid Command Line Processor command

Running following statement in DB2 CLP (Command Window)
db2 "truncate table MYSCHEMA.TABLEA immediate"
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0969N There is no message text corresponding to SQL error "-20356" in the
message file on this workstation. The error was returned from module
"SQLNQBE2" with original tokens "MYSCHEMA.TABLEA".
Can some please tell me what I'm doing wrong or what I'm missing? I'm trying to simply truncate from a single table and I'm getting the following error message. Not sure what I'm doing wrong. I've tried it with/without quotes, with/without schema, with/without immediate. I've also tried in Command Editor (remove db2 and quotes) and still not working. I'm using:
DB2/AIX64 9.7.9
Also, I have delete privilege as I am able to delete records but I want to truncate.
Thanks in advance!
The version of the DB2 client you're using doesn't seem to match that of the server, this is why you cannot see the actual error message for SQLCODE -20356. If you could, you'd see this:
The table MYSCHEMA.TABLEA cannot be truncated because DELETE triggers
exist for the table, or the table is the parent in a referential
constraint.
Further explanation and suggested actions can be found, as usual, in the fine manual.
ALTER TABLE MYSCHEMA.TABLEA ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE
or
import from /dev/null of del replace into MYSCHEMA.TABLEA
I had this problem recently too. In my case I had to do a COMMIT WORK right before TRUNCATE. This solved my problem. Please try and tell us if this helped.

Strange SQL Server Error That Only Occurs On One Table

I have a simple SQL statement:
INSERT INTO table_name (column_name) VALUES ("test value")
This works on any other table I make, but I'm trying to insert values into a table someone else made. I get this strange error and have no idea of what to make of it. I'm not a MS SQL expert, so I appreciate any help I can get.
Msg 4701, Level 16, State 1, Procedure MainPayloadParserTrigger, Line 31
Cannot find the object "DataSplitDB" because it does not exist or you do not have permissions.
The key is in the error message. See the Procedure MainPayloadParserTrigger in the message? It appears the other person who created the table has an insert trigger associated with the table and it is causing the error by something it is trying to do.