August 31, 2005 at 6:42 am
I found this in the SQL books online. Print command returns a user message to the client. So I create a very simple trigger for table CustomerBudget in SQL server:
Create trigger [test] on customerBudget
for insert
as
begin
print "This is a test"
end
Then I go to MS access, do an ODBC link to the table, insert one record to the linked table but I didn't see the message: "This is a test".
I wonder if anybody can help me with this print command or other ways to display a message to client in a trigger. Thank you
August 31, 2005 at 6:49 am
I think you're getting your PRINT output, but Access is losing it for you.
You could create a work table and instead of using PRINT, use an INSERT into that work table with the message you want to see.
September 1, 2005 at 7:23 am
The PRINT command will work if you're in Query Analyzer, but it is a message and not part of the data results. Access isn't expecting extra messages, and I'm not even sure where you think it would be displayed.
I don't know why you're using Access as an interface to SQL Server for testing, but stop doing it. We'll forgive you this time.
September 3, 2005 at 3:46 pm
Try this, instead...
SELECT "This is a test"
--Jeff Moden
Change is inevitable... Change for the better is not.
September 4, 2005 at 8:47 am
..except you'd want to change the double quotes to single...
SELECT 'This is a test'
**ASCII stupid question, get a stupid ANSI !!!**
September 4, 2005 at 8:59 am
THAT's what I get for being in a hurry! Thanks, Sushila...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 4, 2005 at 9:05 am
anytime jeff!
seeing as how you always get everything right (hurry or not) this was probably a one-time catch!
**ASCII stupid question, get a stupid ANSI !!!**
September 4, 2005 at 9:20 am
Now, I'm blushing But I haven't caught you yet and that's even better
--Jeff Moden
Change is inevitable... Change for the better is not.
September 4, 2005 at 12:42 pm
it's no consolation jeff - remi'll tell you (& i'll spare him the trouble of saying so) that it's only a matter of time!
**ASCII stupid question, get a stupid ANSI !!!**
September 4, 2005 at 1:27 pm
It's also a matter of missed opportunities .
September 4, 2005 at 4:22 pm
ah - ever the perfect gentleman! thx. remi!
**ASCII stupid question, get a stupid ANSI !!!**
September 5, 2005 at 12:59 am
I like to be accurate .
September 6, 2005 at 6:14 am
Thank you for all your help. I will try the Select 'This is a test' statement.
September 6, 2005 at 10:06 am
Using SELECT inside a trigger may work, but it is a worse crime against nature than using Access as your front end for this kind of development & testing. You still haven't given any reason for not using Query Analyzer (where the PRINT will work).
From BOL:
It is recommended that a trigger not return any results. This is because special handling for these returned results must be written into every application in which modifications to the trigger table are allowed. To prevent any results from being returned from a trigger, do not include either SELECT statements or variable assignments in the definition of the trigger. If variable assignment must occur in a trigger, use a SET NOCOUNT statement at the beginning of the trigger to eliminate the return of any result sets.
September 6, 2005 at 10:10 am
Basically, this is what I want. I have an SQL server database and a Visual Foxpro application connecting to it. I can't change any code in the Visual Foxpro application (front end ). We bought it as a package. So I wonder if I can create triggers to send some message to the client when people insert a Sales order or do something else.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply