Hej
> Hvis jeg ikke tager meget fejl, så kan man få MS-SQL til at eksekvere et
> bestemt script på et bestemt tidspunkt?
Ja se punkt 1 om hvordan man gør
> Kan man også få SQL-serveren til at køre et script der afsender en mail
> med
> data fra en database?
Ja læs om punkt 2 xp_sendmail og dens opsætning
> CASE:
> Jeg har et forum på min hjemmeside. Én gang om ugen kunne jeg godt tænke
> mig
> at få tilsendt en mail med alle de indlæg der måtte være kommet siden
> sidst.
>
> Kan det lade sig gøre?
Ja søg på google og se hvordan man gør med sp_sendmail hvis dette ikke hjælp
ellers skriv igen
Hilsen
Michael
-------------------------BEGIN PUNKT
1----------------------------------------
How to create a job (Enterprise Manager)
To create a job
Expand a server group, and then expand a server.
Expand Management, and then expand SQL Server Agent.
Right-click Jobs, and then click New Job.
In the Name box, enter a name for the job.
Clear the Enabled check box if you do not want the job to be run immediately
following its creation. For example, if you want to test a job before it is
scheduled to run, disable the job.
Under Source, do one of the following:
Click Target local server if the job should run on this server only. Skip to
Step 9 if you select this option.
Click Target multiple servers if the job should run on other servers. Then
click Change.
This option is enabled only if the server is a master server.
In the Change Job Target Servers dialog box, on the Available Servers tab,
click a server, and then click the right arrow to move the server to the
Selected target servers list.
Click OK to return to the New Job Properties dialog box.
In the Owner list, select a user to be the owner of the job.
In the Description box, enter a description of what the job does. The
maximum number of characters is 512.
-------------------------END PUNKT 1----------------------------------------
-------------------------BEGIN PUNKT
2----------------------------------------
xp_sendmail
Sends a message and a query result set attachment to the specified
recipients.
Syntax
xp_sendmail {[@recipients =] 'recipients [;...n]'}
[,[@message =] 'message']
[,[@query =] 'query']
[,[@attachments =] 'attachments [;...n]']
[,[@copy_recipients =] 'copy_recipients [;...n]'
[,[@blind_copy_recipients =] 'blind_copy_recipients [;...n]'
[,[@subject =] 'subject']
[,[@type =] 'type']
[,[@attach_results =] 'attach_value']
[,[@no_output =] 'output_value']
[,[@no_header =] 'header_value']
[,[@width =] width]
[,[@separator =] 'separator']
[,[@echo_error =] 'echo_value']
[,[@set_user =] 'user']
[,[@dbuse =] 'database']
Arguments
[@recipients =] 'recipients [;...n]'
Is the semicolon-separated list of the recipients of the mail.
n
Is a placeholder indicating that more than one recipient, copy_recipient, or
blind_copy_recipient can be specified.
[@message =] 'message'
Is the message to be sent. message can be up to 8,000 bytes.
[@query =] 'query'
Is a valid Microsoft® SQL ServerT query, the result of which is sent in
mail. xp_sendmail uses a bound connection for the query parameter. The query
connection made by SQL Mail is not blocked by locks held by the client that
issues the xp_sendmail request. This makes xp_sendmail easier to use from
within triggers. The query statement, however, cannot refer to the logical
inserted and deleted tables that are only available within a trigger. query
can be up to 8,000 bytes.
[@attachments =] 'attachments [;...n]'
Is a semicolon-separated list of files to attach to the mail message.
[@copy_recipients =] 'copy_recipients [;...n]'
Is the semicolon-separated list identifying the recipients of a copy of the
mail (cc:'ing).
[@blind_copy_recipients =] 'blind_copy_recipients [;...n]'
Is an optional semicolon-separated list identifying recipients of a blind
copy of the mail (bcc:'ing).
[@subject =] 'subject'
Is an optional parameter specifying the subject of the mail. If subject is
not specified, SQL Server Message is the default.
[@type =] 'type'
Is the input message type based on the MAPI mail definition:
IP[M | C].Vendorname.subclass
If type is NULL, message types beginning with IPM appear in the inbox of the
mail client and are found or read by xp_findnextmsg. Message types beginning
with IPC do not appear in the inbox of the mail client and must be found or
read by setting the type parameter. The default is NULL.
For more information about using custom message types, see the Microsoft
Windows NT Resource Kit or the Microsoft Mail Technical Reference, available
separately.
[@attach_results =] 'attach_value'
Is an optional parameter specifying the result set of a query should be sent
in mail as an attached file instead of being appended to the mail. If
attachments is not NULL and attach_results is true, the first file name in
attachments is used as the file name for the results. If attachments is
NULL, a file name is generated with a .txt extension. The default is FALSE,
which means that the result set is appended to the message.
[@no_output =] 'output_value'
Is an optional parameter that sends the mail but does not return any output
to the client session that sent the mail. The default is FALSE, which means
that the client session of SQL Server receives output.
[@no_header =] 'header_value'
Is an optional parameter that sends the query results in mail but does not
send column header information with the query results. The default is FALSE,
which means that column header information is sent with the query results.
[@width =] width
Is an optional parameter setting the line width of the output text for a
query. This parameter is identical to the /w parameter in the isql utility.
For queries producing long output rows, use width with attach_results to
send the output without line breaks in the middle of output lines. The
default width is 80 characters.
[@separator =] 'separator'
Is the column-separator string for each column of the result set. By
default, the column-separator is a blank space. Use of a column-separator
allows easier accessibility of the result set from spreadsheets and other
applications. For example, use separator with attach_results to send files
with comma-separated values.
[@echo_error =] 'echo_value'
When true, causes SQL Mail to capture any server messages or DB-Library
errors encountered while running the query and append them to the mail
message rather than writing them to the error log. Also, a count of rows
returned/rows affected is appended to the mail message.
Note When echo_error is true, xp_sendmail returns a status of 0 (success) if
the mail is successfully sent, even if DB-Library errors or messages are
encountered or the query returns no results.
[@set_user =] 'user'
Is the security context in which the query should be run. If user is not
specified, the security context defaults to that of the user executing
xp_sendmail.
[@dbuse =] 'database'
Is the database context in which the query should be run. The default is
NULL, which means the user is placed in the default database.
Return Code Values
0 (success) or 1 (failure)
Result Sets
xp_sendmail returns this message:
Mail sent.
-------------------------END PUNKT 2----------------------------------------
|