Printers

  • Client Id : The client for whom this printer is being monitored
  • Printer Id: The unique identifier of this printer,
  • Reboot Count: The number of times the printer job id counter has restarted,
  • Name : The name by which the printer is known,
  • Location : Content of the location part of the printer settings dialog,
  • Comment : Content of the comments part of the printer settings dialog,
  • Server Name : Name of the machine on which the printer is hosted,
  • Share Name : Name that the printer is shared as,
  • Port Name : Port (e.g. LPT1: etc) that the printer is on ,
  • Driver Name : Name of the printer driver,
  • Seperator Filename : Name of a file (if any) used as the job seperator template,
  • Print Processor : Name of the print processor the printer uses (e.g. WINPRINT) ,
  • Default Data Type : Print job data type to use by default - e.g. RAW or EMF,
  • Parameters : Additional parameters used by the printer,
  • Monitor : True to monitor print jobs on this printer,
  • User Name : User who made the last change to this record,
  • Timestamp : Date and time this record was last updated

Notes

  1. The reboot count is needed because each print job has an unique identifier for the printer but that unique number resets whenever the server is rebooted - therefore we need an additional reboot count in the print job key field
  2. The client id differentiates between clients using the same database to store their print job logging - for example if the database is centrally hosted (e.g. SQL Azure)
  3. Not every version of SQL Server supports the Hostname() default

Code

CREATE TABLE [Printers](
	[Client Id] [uniqueidentifier] NOT NULL,
	[Printer Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
	[Reboot Count] [int] NOT NULL CONSTRAINT [DF_Printers_Reboot Count]  DEFAULT ((0)),
	[Name] [nvarchar](220) NOT NULL,
	[Location] [nvarchar](1024) NULL,
	[Comment] [nvarchar](1024) NULL,
	[Server Name] [varchar](255) NULL CONSTRAINT [DF_Printers_Server Name]  DEFAULT (host_name()),
	[Share Name] [varchar](255) NULL,
	[Port Name] [varchar](255) NULL,
	[Driver Name] [varchar](255) NULL,
	[Seperator Filename] [varchar](255) NULL,
	[Print Processor] [varchar](255) NULL,
	[Default Data Type] [varchar](255) NULL,
	[Parameters] [varchar](1024) NULL,
	[Monitor] [bit] NOT NULL CONSTRAINT [DF_Printers_Monitor]  DEFAULT ((1)),
	[User Name] [varchar](220) NOT NULL CONSTRAINT [DF_Printers_User Name]  DEFAULT (suser_sname()),
	[Timestamp] [datetime] NOT NULL CONSTRAINT [DF_Printers_Timestamp]  DEFAULT (getdate()),
 CONSTRAINT [PK_Printers] PRIMARY KEY CLUSTERED 
(
	[Client Id] ASC,
	[Printer Id] ASC
)) ON [PRIMARY]

Last edited Dec 7, 2009 at 6:49 PM by Merrion, version 5

Comments

Merrion Nov 29, 2009 at 9:10 PM 
"Id" field to be renamed to "Printer Id"