Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #648

Temp Variables in MS SQL Scripts

From BrianDP <bdp222@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Temp Variables in MS SQL Scripts
Date 2011-09-07 10:38 -0700
Organization http://groups.google.com
Message-ID <a04bd3b2-1ca4-49b8-bd5a-bcc13bd3ae0a@eb1g2000vbb.googlegroups.com> (permalink)

Show all headers | View raw


This is a script that the sql front end client wrote for me,-  it
inserts a field toward the top of the layout for an autonumber/
Autoincrement field.  I would like to know if you can replace the name
Personnl1 toward the top with a variable name and replace the variable
down into the script, so I wouldnt' have to type that name over and
over.

Help!

-Brian
a


USE [Personnel]
GO

/****** Object:  Table [dbo].[PERSONNL1]    Script Date: 09/07/2011
12:27:06 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
/*  CREATE TABLE Persons (P_Id int NOT NULL AUTO_INCREMENT, */
/*  job_id  smallint IDENTITY(1,1)PRIMARY KEY CLUSTERED,  */

CREATE TABLE [dbo].[PERSONNL1B](
    [AutoID] [smallint] IDENTITY(1,1)PRIMARY KEY CLUSTERED NOT NULL,
	[EMPID] [nvarchar](6) NULL,
	[EMPNMBR] [nvarchar](3) NULL,
	[LNAME] [nvarchar](15) NULL,
	[FNAME] [nvarchar](15) NULL,

			.
			.
			.
			.
			.

	[OTHREXMP] [float] NULL,
	[TITLE] [nvarchar](20) NULL,
	[JOBDSC_CDE] [nvarchar](3) NULL,
	[RPT_STATUS] [nvarchar](1) NULL,
	[AUTH_DRIVR] [nvarchar](1) NULL,
	[EAFCODE] [float] NULL,
	[PERC401K] [float] NULL
) ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'AllowZeroLength',
@value=N'False' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'AppendOnly', @value=N'False' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'Attributes', @value=N'2' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'CollatingOrder',
@value=N'1033' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'DataUpdatable',
@value=N'False' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'Name', @value=N'EMPID' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO

EXEC sys.sp_addextendedproperty @name=N'OrdinalPosition',
@value=N'0' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B',
@level2type=N'COLUMN',@level2name=N'EMPID'
GO
			.
			.

EXEC sys.sp_addextendedproperty @name=N'Attributes', @value=N'0' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

EXEC sys.sp_addextendedproperty @name=N'DateCreated',
@value=N'5/10/2002 1:02:17 PM' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

EXEC sys.sp_addextendedproperty @name=N'LastUpdated',
@value=N'8/17/2011 11:09:42 AM' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

EXEC sys.sp_addextendedproperty @name=N'Name',
@value=N'PERSONNL1_local' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

EXEC sys.sp_addextendedproperty @name=N'RecordCount', @value=N'60' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

EXEC sys.sp_addextendedproperty @name=N'Updatable', @value=N'True' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'PERSONNL1B'
GO

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

Temp Variables in MS SQL Scripts BrianDP <bdp222@gmail.com> - 2011-09-07 10:38 -0700
  Re: Temp Variables in MS SQL Scripts Erland Sommarskog <esquel@sommarskog.se> - 2011-09-07 23:05 +0200
  Re: Temp Variables in MS SQL Scripts "Fred." <ghrno-google@yahoo.com> - 2011-09-13 07:50 -0700

csiph-web