In SQL Server, we can get the last inserted record using inserted table in triggers. I know the equivalent MySQL statement is NEW. But the question is how to implement that.
A snippet is attached herewith what it shows in SQL Server. I want the very same thing in MySQL. Will it be possible to do that?
I want the output as:
Please give the total implementation. I've tried NEW in different ways those didn't work out.
Thanks.
Related
I have a MYSQL database with a query. The query only works if I manually type in the data with MYSQL Admin or with the following statement $sn="x-xxx"; It will not return results if i pass $sn to the database from a form even though the $sn get inserted into the database just fine. I can look at the database and see that it's there. Not sure if why the query would only pull down the records I manually imputed.
Thanks for the help guys. I found that by passing the variable from page to page that a space was being added to the variable. I used:
$sn=preg_replace('/\s+/', '', $sn); and var_dump($sn); to strip the space and to check what was being posed. Wow 5 full days trying to find this. Thanks to everybody who answered.
I have a remote SQL Server database that I don't want to copy because of it's size. I want to just remotely import it's creation query to duplicate it's structure locally.
I know there was a query for it but lost somewhere my book about it. I ask for name of that query method that I described. If got any questions please don't hesitate to ask.
I found it. It's SHOW CREATE TABLE http://dev.mysql.com/doc/refman/5.0/en/show-create-table.html
My requirement is to create a stored procedure that joins two tables and inserts it into a remote server table.
How can I solve this without using ssis and any import/export data?
please
use the search before asking your question
Be more specific, stackoverflow is not here to write your whole program, people assist you
Use punctations marks and have a look at your format
Your question
Have a look at this, it shows you how to do that. You can first add a linked server(thats the destionation in your case) and then use it for your insert statement.
Is it possible to update a table in SQL Server using a trigger in MySQL. The scenario is like this.
When a table is updated in MySQL, a corresponding update is to be done in SQL Server for the purpose of syncing certain fields. I understand that the reverse is possible using a linked server in SQL Server.
You can write a UDF function that would update data in the SQL Server. Then call this UDF from the trigger.
Here's some information which may be of help regarding linking SQL Server and MySQL
http://forums.mysql.com/read.php?60,123221,123221
I'm afraid I've no personal experience in the matter as I thankfully have MySQL servers across the board, however had a scan through the links in the above and at least one of them should be able to assist.
I have a very weird situation here. During development I discovered that one of my tables got more and more empty rows (the Id field is auto-incremented and was set). No insert statement was run from my code.
I use SQL Manager 2010 Lite for MySQL to inspect the data, and it turns out that when I Execute the select statement from there, the empty row gets added.
Has anyone else experienced this? All i do is right click the table, select 'Script to NEW SQL Editor' and Select. When I press Execute, the row gets added.
Not really an answer - I'm using phpmyadmin myself - but you could try setting one of the columns to not null? Just to see what happens, and what kind of error message you get? And you could also check to see if there are any stored procedures that could cause this.
Normally I would post this in a comment, but I don't have enough rep to do that yet, sorry...