SA4
asked on
rerunable query
Hello,
I have this script that insert few records in two tables. I have to modify it so it colud be rerun.
Is there a simply way to do that.
thanks in advance.
script:
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
SET NOCOUNT ON;
GO
DECLARE @GID UNIQUEIDENTIFIER
INSERT INTO Error (ErrorCode) VALUES ('MPCD0102')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0102')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'There is no workspace version of the SiteNavigation for this user to check in.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0103')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0103')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'Display start date can not be more than 24 hours in the past.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0104')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0104')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'Workspace version is already checked out.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0105')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0105')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'@AuthenticatedUser_UserI D is Required.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0106')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0106')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'SiteNavigationVersion can not be NULL.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0107')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0107')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'DisplayOrder can only be changed on current and future versions.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0108')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0108')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'DisplayOrder can not be changed on excluded versions.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0109')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0109')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'Adds are not allowed for a non-Workspace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0110')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0110')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'Removes are not allowed for a non-Workspace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0111')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0111')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'Moving categories to a different parent is not allowed for a non-WorkSpace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0112')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0112')
INSERT INTO [CMS].[dbo].[Localization] ([Localiza tionGID] ,[LangID] ,[Phrase])
VALUES (@GID ,10000000 ,'There is no workspace version of the SiteNavigation for this user to save.')
I have this script that insert few records in two tables. I have to modify it so it colud be rerun.
Is there a simply way to do that.
thanks in advance.
script:
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
SET NOCOUNT ON;
GO
DECLARE @GID UNIQUEIDENTIFIER
INSERT INTO Error (ErrorCode) VALUES ('MPCD0102')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0102')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'There is no workspace version of the SiteNavigation for this user to check in.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0103')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0103')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'Display start date can not be more than 24 hours in the past.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0104')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0104')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'Workspace version is already checked out.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0105')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0105')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'@AuthenticatedUser_UserI
INSERT INTO Error (ErrorCode) VALUES ('MPCD0106')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0106')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'SiteNavigationVersion can not be NULL.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0107')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0107')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'DisplayOrder can only be changed on current and future versions.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0108')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0108')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'DisplayOrder can not be changed on excluded versions.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0109')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0109')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'Adds are not allowed for a non-Workspace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0110')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0110')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'Removes are not allowed for a non-Workspace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0111')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0111')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'Moving categories to a different parent is not allowed for a non-WorkSpace version of the SiteNavigation.')
INSERT INTO Error (ErrorCode) VALUES ('MPCD0112')
SET @GID = (SELECT ErrorGID FROM Error WHERE ErrorCode = 'MPCD0112')
INSERT INTO [CMS].[dbo].[Localization]
VALUES (@GID ,10000000 ,'There is no workspace version of the SiteNavigation for this user to save.')
can't you associate with a scheduler, just like backups
ASKER
this script needed to ran in the build, and for the recovery.
Actually save this script as a Stored Procedure and you can Call when you need it.
It can be schedule for automation or run manually.
It can be schedule for automation or run manually.
ASKER
thanks for your responce b_haynes, but making it a Sproc will save it as an object in the db that I don't want. it will be run through cmd file.
That's why it (sql server) supports script files... but you already knew that. You
could use a script file and run OSQL from the SQL Server Agent. That way
you only have one file.
Check SQL server online for the process.
could use a script file and run OSQL from the SQL Server Agent. That way
you only have one file.
Check SQL server online for the process.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks Crag, I was looking for something like that. But there is exsiting data in the table that might be same as 'MPCD0102'-- 'MPCD0112' which i don't want to delete. so I'll use if statment to check if the ErrorGID already exist if not then insert.