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


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

Temp Variables in MS SQL Scripts

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!eb1g2000vbb.googlegroups.com!not-for-mail
From BrianDP <bdp222@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Temp Variables in MS SQL Scripts
Date Wed, 7 Sep 2011 10:38:03 -0700 (PDT)
Organization http://groups.google.com
Lines 127
Message-ID <a04bd3b2-1ca4-49b8-bd5a-bcc13bd3ae0a@eb1g2000vbb.googlegroups.com> (permalink)
NNTP-Posting-Host 24.227.68.202
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1315417083 23310 127.0.0.1 (7 Sep 2011 17:38:03 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Wed, 7 Sep 2011 17:38:03 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info eb1g2000vbb.googlegroups.com; posting-host=24.227.68.202; posting-account=g4SRewoAAADZg-atAnMNtO2TExdeq2g9
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order ARLUEHNKC
X-HTTP-UserAgent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C),gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:648

Show key headers only | 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