Hello All, any code immediately following an 'N' is throwing an error. Please advise on why. TIA.

set @localized_string_AddRole_Failed = N'Failed adding the ''state_persistence_users'' role'

DECLARE @ret int, @Error int
IF NOT EXISTS( SELECT 1 FROM [dbo].[sysusers] WHERE name=N'state_persistence_users' and issqlrole=1 )
 BEGIN

	EXEC @ret = sp_addrole N'state_persistence_users'

	SELECT @Error = @@ERROR

	IF @ret <> 0 or @Error <> 0
		RAISERROR( @localized_string_AddRole_Failed, 16, -1 )
 END
GO


--
-- TABLE InstanceState
--
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InstanceState]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[InstanceState]
GO
CREATE TABLE [dbo].[InstanceState] (
	[uidInstanceID] [uniqueidentifier] NOT NULL ,
	[state] [image] NULL ,
	[status] [int] NULL ,
	[unlocked] [int] NULL ,
	[blocked] [int] NULL ,
	[info] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[modified] [datetime] NOT NULL,
	[ownerID] [uniqueidentifier] NULL ,
	[ownedUntil] [datetime] NULL,
	[nextTimer] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE  UNIQUE CLUSTERED  INDEX [IX_InstanceState] ON [dbo].[InstanceState]([uidInstanceID]) ON [PRIMARY]
-- CREATE  NONCLUSTERED  INDEX [IX_InstanceState_Ownership] ON [dbo].[InstanceState]([ownerID],[ownedUntil])
GO


--
-- TABLE CompletedScope
--
IF EXISTS (SELECT * FROM [dbo].[sysobjects] WHERE id = object_id(N'[dbo].[CompletedScope]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[CompletedScope]
GO

You need to declare the variable.

Declare @localized_string_AddRole_Failed Nvarchar(4000)
set @localized_string_AddRole_Failed = N'Failed adding the ''state_persistence_users'' role'

DECLARE @ret int, @Error int
IF NOT EXISTS( SELECT 1 FROM [dbo].[sysusers] WHERE name=N'state_persistence_users' and issqlrole=1 )
 BEGIN

	EXEC @ret = sp_addrole N'state_persistence_users'

	SELECT @Error = @@ERROR

	IF @ret <> 0 or @Error <> 0
		RAISERROR( @localized_string_AddRole_Failed, 16, -1 )
 END
GO


--
-- TABLE InstanceState
--
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InstanceState]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[InstanceState]
GO
CREATE TABLE [dbo].[InstanceState] (
	[uidInstanceID] [uniqueidentifier] NOT NULL ,
	[state] [image] NULL ,
	[status] [int] NULL ,
	[unlocked] [int] NULL ,
	[blocked] [int] NULL ,
	[info] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[modified] [datetime] NOT NULL,
	[ownerID] [uniqueidentifier] NULL ,
	[ownedUntil] [datetime] NULL,
	[nextTimer] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE  UNIQUE CLUSTERED  INDEX [IX_InstanceState] ON [dbo].[InstanceState]([uidInstanceID]) ON [PRIMARY]
-- CREATE  NONCLUSTERED  INDEX [IX_InstanceState_Ownership] ON [dbo].[InstanceState]([ownerID],[ownedUntil])
GO


--
-- TABLE CompletedScope
--
IF EXISTS (SELECT * FROM [dbo].[sysobjects] WHERE id = object_id(N'[dbo].[CompletedScope]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[CompletedScope]
GO
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.