Microsoft SQL Server 2005 Service Pack 1 (SP1) yükledikten sonra aşağıdaki davranışla karşılaşabilirsiniz:
Işleri simgeleri kullanan işlem adımları içerdiğinde, SQL Server Agent işlerinin başarısız.
Aşağıdaki hata iletisini alıyorsunuz:
Işlem adımı, bir veya daha fazla simge içerir. Işi çalıştırmak için önce SQL Server 2005 Service Pack 1 veya sonraki sürümleri, tüm iş adımlara simgeleri bir makroyla güncelleştirilmesi gerekir.
Not Bu sorun, yapı 2046 veya sonraki sürümleri SQL Server 2005 ile oluşur.
SQL Server 2005 SP1'de SQL Server Agent iş adım token sözdizimi değiştirdi. Artık, iş adımda kullanılan tüm simgeleri içeren bir çıkış makrosu eklemeniz gerekir. Bir çıkış makrosu eklemezseniz, bu işlemi adımları başarısız olur. Aşağıdaki tablo, çıkış makrolarını listeler.
Bu tabloyu kapaBu tabloyu aç
Çıkış makrosu
Açıklama
<a1>$</a1> (ESCAPE_SQUOTE (TokenName))
Bu makro, kesme (') <a0>simge değiştirme</a0> dizesindeki escapes. Makro bir kesme işareti iki kesme ile değiştirir.
<a1>$</a1> (ESCAPE_DQUOTE (TokenName))
Bu makro <a0>simge değiştirme</a0> dizesindeki tırnak işareti ('') escapes. Makro iki tırnak işareti tek tırnak işareti) yerini alır.
<a1>$</a1> (ESCAPE_RBRACKET (TokenName))
Bu makro, sağ köşeli ayraç (]) <a0>simge değiştirme</a0> dizesindeki escapes. Makro bir sağ ayraç iki sağ köşeli ayraç ile değiştirir.
<a1>$</a1> (ESCAPE_NONE (TokenName))
Makro, bir belirteç herhangi bir karakter dizesindeki escaping olmadan değiştirir. Bu makro, simge değiştirme dizeleri güvenilen kullanıcıların yalnızca burada beklenen ortamlarda geriye dönük uyumluluk desteklemek için sağlanır.
Örneğin, bir iş adım A DBN token'ı kullanan aşağıdaki Transact-SQL deyimini içeriyor olabilir:
CREATE DATABASE [$(A-DBN)]
bu örnekte, belirteç sözdizimi için aşağıdaki sözdizimini güncelleştirmelisiniz:
CREATE DATABASE [$(ESCAPE_RBRACKET(A-DBN))]
bu değişiklik, bir çıkış makrolarını gerekli değil önceki SQL Server 2005 davranış, farklı.
Bu sorunu gidermek için <a0></a0>, ya da tümünü Güncelleştir veya yeni token sözdizimine simgelerini kullanmak yalnızca belirli işler. Bunu yapmak için <a0></a0>, sp_AddEscapeNoneToJobStepTokens saklı yordamı kullanın. Aşağıdaki Transact-SQL komut dosyası kullanarak, bu saklı yordam oluşturabilirsiniz.
Not SQL Server 2005 SP1 Yapı yüklemeniz <a1>Yapı</a1> 2046 veya sonraki bir derlemesi olduğundan emin olun. Ayrıca, u (Yürüt) tıklatıp komut dosyasını
-- This script is used to automatically edit SQL Agent job steps so that
-- unescaped tokens are prefaced with the ESCAPE_NONE syntax that was added in
-- SQL Server 2005 SP1.
if (@@microsoftversion < 0x90007FE)
BEGIN
RAISERROR('This script should only be run on at least SQL Server 2005 SP1.', 20, 127) WITH LOG
return
END
use msdb
go
if exists (select * from sys.objects where name = N'fn_PrefaceTokensWithEscapeNone' and type = 'FN')
drop function fn_PrefaceTokensWithEscapeNone
go
-- This function manipulates @commands so that all bare tokens
-- are prefaced with ESCAPE_NONE.
create function fn_PrefaceTokensWithEscapeNone(@commands nvarchar(max)) RETURNS nvarchar(max)
AS
BEGIN
if (@commands IS NULL)
BEGIN
return @commands
END
-- In order to let this script run under SQLCMD mode, we define
-- the special "$(" variable start string by concatenation so that
-- sqlcmd mode does not think that we are defining one of its variables.
declare @strVariableStart nchar(2)
select @strVariableStart = N'$' + N'('
declare @idxTokenStart int
select @idxTokenStart = CHARINDEX(@strVariableStart, @commands)
while (@idxTokenStart != 0 and @idxTokenStart is not null)
BEGIN
declare @idxCloseParen int
select @idxCloseParen = CHARINDEX(N')', SUBSTRING(@commands, @idxTokenStart, LEN(@commands)))
-- Error checking. If there is no close parenthesis, return.
if (0 = @idxCloseParen)
BEGIN
return @commands
END
-- Deduce the token variable.
declare @tokenLen int
select @tokenLen = @idxCloseParen - LEN(@strVariableStart) - 1
declare @token nvarchar(max)
select @token = SUBSTRING(@commands, @idxTokenStart + LEN(@strVariableStart), @tokenLen)
-- Verify if @token contains a mis-matched number of open and
-- close parens. This behavior could happen if invalid syntax is
-- in a comment block. If so, skip to the next token.
declare @idx int
declare @cOpenParens int
declare @cCloseParens int
select @cOpenParens = 0
select @idx = CHARINDEX(N'(', @token);
while (@idx != 0)
BEGIN
select @cOpenParens = @cOpenParens + 1
select @idx = CHARINDEX(N'(', @token, @idx + 1);
END
select @cCloseParens = 0
select @idx = CHARINDEX(N')', @token);
while (@idx != 0)
BEGIN
select @cCloseParens = @cCloseParens + 1
select @idx = CHARINDEX(N')', @token, @idx + 1);
END
-- Special case for the WMI token.
if (N'WMI(' = SUBSTRING(@token, 1, LEN(N'WMI(')))
BEGIN
select @cOpenParens = @cOpenParens - 1
END
if ((@cOpenParens = @cCloseParens) and
(N'ESCAPE_NONE(' != SUBSTRING(@token, 1, LEN(N'ESCAPE_NONE('))) and
(N'ESCAPE_SQUOTE(' != SUBSTRING(@token, 1, LEN(N'ESCAPE_SQUOTE('))) and
(N'ESCAPE_DQUOTE(' != SUBSTRING(@token, 1, LEN(N'ESCAPE_DQUOTE('))) and
(N'ESCAPE_RBRACKET(' != SUBSTRING(@token, 1, LEN(N'ESCAPE_RBRACKET('))))
BEGIN
select @commands = STUFF(@commands, @idxTokenStart + LEN(@strVariableStart), @tokenLen, N'ESCAPE_NONE(' + @token + N')')
END
select @idxTokenStart = CHARINDEX(@strVariableStart, @commands, @idxTokenStart + 1)
END
return @commands
END
go
if exists (select * from sys.objects where name = N'sp_AddEscapeNoneToJobStepTokens' and type = 'P')
drop procedure sp_AddEscapeNoneToJobStepTokens
go
-- This procedure allows you to update jobs so that bare tokens
-- are prefaced with ESCAPE_NONE. By default, all jobs are updated.
-- You can optionally specify @job_name, @job_id, or @owner_name
-- to limit the jobs that will be affected.
CREATE PROCEDURE sp_AddEscapeNoneToJobStepTokens
(
@job_name nvarchar(128) = null,
@job_id uniqueidentifier = null,
@owner_name nvarchar(256) = null
)
AS
-- Find the jobs to update. These jobs must match all of the input
-- criteria, unless all of the inputs are null. In this case,
-- examine all jobs. The jobs must also be jobs created locally,
-- such as sysjobs.originating_server_id = 0. These jobs should not be a job that we run
-- because another server told us to. Furthermore, if the job
-- is local but it is meant to be run on a target server, we send an
-- update for the job.
declare @jobsToUpdate TABLE (job_id uniqueidentifier not null)
insert into @jobsToUpdate
select job_id
from sysjobs
where originating_server_id = 0 -- local jobs
and ((COALESCE(@job_name, sysjobs.name) = sysjobs.name) and
(COALESCE(@job_id, sysjobs.job_id) = sysjobs.job_id) and
(COALESCE(@owner_name, suser_sname(sysjobs.owner_sid)) = suser_sname(sysjobs.owner_sid)))
-- Now find the job steps to update, creating the new command by using
-- fn_PrefaceTokensWithEscapeNone.
declare @jobStepsToUpdate TABLE (job_id uniqueidentifier not null,
step_id int not null,
command_old nvarchar(max) null,
command_new nvarchar(max) null,
output_file_old nvarchar(max) null,
output_file_new nvarchar(max) null)
insert into @jobStepsToUpdate
(job_id, step_id, command_old, command_new, output_file_old, output_file_new)
select job_id, step_id, command, dbo.fn_PrefaceTokensWithEscapeNone(command), output_file_name, dbo.fn_PrefaceTokensWithEscapeNone(output_file_name)
from sysjobsteps
where sysjobsteps.job_id =
(select job_id
from @jobsToUpdate
where job_id = sysjobsteps.job_id)
-- Now we update the actual job step commands. We do this first before
-- we push out the updated jobs to the target servers so the
-- target servers actually get the updated version.
declare @updated_job_id uniqueidentifier
declare @updated_job_step_id int
declare @updated_job_step_command nvarchar(max)
declare @updated_job_step_output_file nvarchar(max)
declare job_steps_cursor CURSOR FOR
select job_id, step_id, command_new, output_file_new
from @jobStepsToUpdate
order by job_id, step_id
OPEN job_steps_cursor
FETCH NEXT from job_steps_cursor into @updated_job_id, @updated_job_step_id, @updated_job_step_command, @updated_job_step_output_file
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
EXEC sp_update_jobstep @job_id = @updated_job_id, @step_id = @updated_job_step_id, @command = @updated_job_step_command, @output_file_name = @updated_job_step_output_file
END
FETCH NEXT from job_steps_cursor into @updated_job_id, @updated_job_step_id, @updated_job_step_command, @updated_job_step_output_file
END
CLOSE job_steps_cursor
DEALLOCATE job_steps_cursor
-- For multiserver jobs, call the sp_post_msx_operation stored procedure to update
-- all the target servers. Note that the sp_post_msx_operation stored procedure is safe
-- to call because it verifies whether the job is really a multiserver job.
declare jobs_cursor CURSOR FOR
select job_id
from @jobsToUpdate
OPEN jobs_cursor
FETCH NEXT from jobs_cursor into @updated_job_id
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
EXEC sp_post_msx_operation @operation = 'UPDATE', @job_id = @updated_job_id
END
FETCH NEXT from jobs_cursor into @updated_job_id
END
CLOSE jobs_cursor
DEALLOCATE jobs_cursor
-- List the jobs that we ran on, including the previous command
-- text. We list all of the job steps, even the ones that we did not
-- update. Otherwise, a jumble of job steps from
-- different jobs run together and the output is not
-- useful.
select N'Warning - Jobs Updated' = N'The following job steps and job output file names were analyzed and potentially updated to add the ESCAPE_NONE macro before any job tokens that were not already escaped. Please review the modified job steps and replace ESCAPE_NONE with the correct escape macro.'
select suser_sname(jobs.owner_sid) as N'Job owner',
jobs.name as N'Job name',
jobs.job_id,
jobStepsUpdated.step_id,
N'Modified' = CASE WHEN jobStepsUpdated.command_new != jobStepsUpdated.command_old or jobStepsUpdated.output_file_new != jobStepsUpdated.output_file_old THEN 1 ELSE 0 END,
N'Command' = jobStepsUpdated.command_new,
N'Previous Command' = jobStepsUpdated.command_old,
N'Output file' = jobStepsUpdated.output_file_new,
N'Previous Output file' = jobStepsUpdated.output_file_old
from sysjobs as jobs, @jobsToUpdate as jobsUpdated, @jobStepsToUpdate as jobStepsUpdated
where jobsUpdated.job_id = jobs.job_id and jobsUpdated.job_id = jobStepsUpdated.job_id
order by 'Job name', jobStepsUpdated.step_id
go
Sp_AddEscapeNoneToJobStepTokens saklı yordamı, komut dosyasını çalıştırdıktan sonra oluşturulur. Bu saklı yordam parametreleri olmadan çalıştırırsanız, varsayılan olarak, tüm işleri güncelleştirecektir. Yalnızca belirli işler güncelleştirmek isterseniz, aşağıdaki üç parametre en az bir boş olmayan değerleri belirtmeniz gerekir:
@ job_name
@ job_id
@ owner_name
Örneğin, aşağıdaki sözdizimini kullanabilirsiniz:
Tüm işleri güncelleştirin:
EXEC sp_AddEscapeNoneToJobStepTokens
Bir iş, iş adı belirterek güncelleştir:
EXEC sp_AddEscapeNoneToJobStepTokens 'MyJob'
Aynı sahibi tarafından ait olan işleri güncelleştirin:
Bu komut, simgeleri içeren tüm işlem adımları ESCAPE_NONE makro ekler. Bu komut dosyasını çalıştırdıktan sonra olabildiğince kısa sürede simgeleri kullanan iş adımlarınız gözden geçirmenizi öneririz. Sonra iş adım içerik için uygun olan diğer çıkış makroları biriyle ESCAPE_NONE makroyu değiştirin.
Not Bir ana sunucu (MSX) ve hedef sunucu (TSX) ortamında çalışıyorsanız, bu çalıştırmalısınız MSX ve TSX the TSX ana işlerine doğru güncelleştirilmiş olduğundan emin olmak için komut dosyası.
Yeni sözdizimini kullanmak için işleri güncelleştirin ve çıkış makrolarını simge değiştirme işlemini adımda SQL Server Agent'ı etkinleştirmek için nasıl kullanılacağı hakkında daha fazla bilgi için SQL Server 2005 Books Online'da (Nisan 2006) veya sonraki sürümleri SQL Server 2005 Books Online'da ","İş yer belirteçleri adımlar kullanma"konusuna bakın.
ÖNEMLİ: Bu makale, bir kişi tarafından çevrilmek yerine, Microsoft makine-çevirisi yazılımı ile çevrilmiştir. Microsoft size hem kişiler tarafından çevrilmiş, hem de makine-çevrisi ile çevrilmiş makaleler sunar. Böylelikle, bilgi bankamızdaki tüm makalelere, kendi dilinizde ulaşmış olursunuz. Bununla birlikte, makine tarafından çevrilmiş makaleler mükemmel değildir. Bir yabancının sizin dilinizde konuşurken yapabileceği hatalar gibi, makale; kelime dağarcığı, söz dizim kuralları veya dil bilgisi açısından yanlışlar içerebilir. Microsoft, içeriğin yanlış çevrimi veya onun müşteri tarafından kullanımından doğan; kusur, hata veya zarardan sorumlu değildir. Microsoft ayrıca makine çevirisi yazılımını sıkça güncellemektedir.
Teşekkürler! Görüşleriniz, destek içeriğimizi geliştirmemize yardımcı olmak için kullanılmaktadır. Diğer yardım seçenekleri için, lütfen Yardım ve Destek Giriş Sayfasını ziyaret edin.