dbTalk Databases Forums  

Escape Template Parameter

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss Escape Template Parameter in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Izorich
 
Posts: n/a

Default Escape Template Parameter - 02-12-2009 , 06:02 PM






SQL Server Management Studio documentation instructions:

To replace template parameters
On the Query menu
click Specify Values for Template Parameters

When I follow those instructions replacment dialog contains several false
positives.
The following two lines demonstrate examples of false positives:

If ascii(substring(@var, @var2, 1)) < 48 OR ascii(substring(@var3, @var4,
1)) > 57

Set @xmlEvent = @xmlEvent + '<elem1>' + Rtrim(Convert(varchar(30), @var1,
126)) + '</elem>'

The statements abover are complex statements that result in template match,
when it is clearly not a template. I'd like to use template feature for a
file like that, but this type of false matching prevents me from using
templates.

Reply With Quote
  #2  
Old   
Robbie Meng
 
Posts: n/a

Default RE: Escape Template Parameter - 02-13-2009 , 04:32 AM






Dear Sir,

As I understood, you want to configure a complex template. if I
misunderstood, please feel free to let me know.

Before going further, I would like to verify the following information:

1. You want to change the example code that you provide to the template?

2. How many parameters do you want to specify? Could you please list them?

If you want to specify multiple parameter and it is a little difficult for
you to write the template, you may refer to the following multiple
parameter template: <template explorer\Database mail\Simple Database Mail
Configuration>. I also copy the content as following for your convenience:

================================================== ===

-------------------------------------------------------------
-- Database Mail Simple Configuration Template.
--
-- This template creates a Database Mail profile, an SMTP account and
-- associates the account to the profile.
-- The template does not grant access to the new profile for
-- any database principals. Use msdb.dbo.sysmail_add_principalprofile
-- to grant access to the new profile for users who are not
-- members of sysadmin.
-------------------------------------------------------------

DECLARE @profile_name sysname,
@account_name sysname,
@SMTP_servername sysname,
@email_address NVARCHAR(128),
@display_name NVARCHAR(128);

-- Profile name. Replace with the name for your profile
SET @profile_name = '<profile_name,sysname,SampleProfile>';

-- Account information. Replace with the information for your account.

SET @account_name = '<account_name,sysname,SampleAccount>';
SET @SMTP_servername = '<SMTP_servername,sysname,your SMTP server name>';
SET @email_address = '<email_address,nvarchar(128),sender email address>';
SET @display_name = '<display_name,nvarchar(128),name of the
sender>';


-- Verify the specified account and profile do not already exist.
IF EXISTS (SELECT * FROM msdb.dbo.sysmail_profile WHERE name =
@profile_name)
BEGIN
RAISERROR('The specified Database Mail profile
(<profile_name,sysname,SampleProfile>) already exists.', 16, 1);
GOTO done;
END;

IF EXISTS (SELECT * FROM msdb.dbo.sysmail_account WHERE name =
@account_name )
BEGIN
RAISERROR('The specified Database Mail account
(<account_name,sysname,SampleAccount>) already exists.', 16, 1) ;
GOTO done;
END;

-- Start a transaction before adding the account and the profile
BEGIN TRANSACTION ;

DECLARE @rv INT;

-- Add the account
EXECUTE @rv=msdb.dbo.sysmail_add_account_sp
@account_name = @account_name,
@email_address = @email_address,
@display_name = @display_name,
@mailserver_name = @SMTP_servername;

IF @rv<>0
BEGIN
RAISERROR('Failed to create the specified Database Mail account
(<account_name,sysname,SampleAccount>).', 16, 1) ;
GOTO done;
END

-- Add the profile
EXECUTE @rv=msdb.dbo.sysmail_add_profile_sp
@profile_name = @profile_name ;

IF @rv<>0
BEGIN
RAISERROR('Failed to create the specified Database Mail profile
(<profile_name,sysname,SampleProfile>).', 16, 1);
ROLLBACK TRANSACTION;
GOTO done;
END;

-- Associate the account with the profile.
EXECUTE @rv=msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = @profile_name,
@account_name = @account_name,
@sequence_number = 1 ;

IF @rv<>0
BEGIN
RAISERROR('Failed to associate the speficied profile with the specified
account (<account_name,sysname,SampleAccount>).', 16, 1) ;
ROLLBACK TRANSACTION;
GOTO done;
END;

COMMIT TRANSACTION;

done:

GO

================================================== ===


Is this helpful?

Please let me know on any updates on the situation.


Best Regards,


Robbie Meng
Microsoft Online Partner support
================================================== ====
PLEASE NOTE:
This newsgroup service currently provides a one business day response time,
Monday through Friday, excluding holidays.
================================================== ====
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.