Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to import Long Script Files 1

Status
Not open for further replies.

ProgrammingB52

Technical User
May 7, 2003
37
0
0
US
I have 2 long script files the first starts with:
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'empExpense')
DROP DATABASE [empExpense]
GO

CREATE DATABASE [empExpense] ON (NAME = N'empExpense_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\empExpense_Data.MDF' , SIZE = 1, FILEGROWTH = 10%) LOG ON (NAME = N'empExpense_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\empExpense_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO

use [empExpense]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_ApprovalWorkflow_ApprovalLevel]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[ApprovalWorkflow] DROP CONSTRAINT FK_ApprovalWorkflow_ApprovalLevel
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_EmployeeApprovalLevels_ApprovalLevel]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[EmployeeApprovalLevels] DROP CONSTRAINT FK_EmployeeApprovalLevels_ApprovalLevel
GO
....and the file goes on etc.........

HOW DO I IMPORT THESE SCRIPT FILES OR RUN THEM IN SQL SERVER 2000?
 
The easiest way is to use the tools that come with SQL 2000, one of them is called Query Analyzer (QA). With out going into too much detail Query Analyzer is a GUI that among other things allows you to execute scripts & store procedures.

Just open QA and create a connection to the server that hosts the database. From the drop down combo box pick a database to run the script against. Then copy and paste the code to the editor pane and run the script (hit the F5 key).

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top