Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do you run a script file against an operating sqlexpress 2008 database

Posted on 2009-05-07
7
325 Views
Last Modified: 2012-05-06
How do you run a script file against an operating sqlexpress 2008 database
0
Comment
Question by:gracemedia
  • 3
  • 3
7 Comments
 
LVL 26

Expert Comment

by:Chris Luttrell
ID: 24331204
Through either Management Studio or SQLCMD at the command line.
(Link for SQL Server Management Studio Express http://msdn.microsoft.com/en-us/library/ms365247.aspx)
0
 
LVL 8

Expert Comment

by:k_rasuri
ID: 24331207
What scrip are you talking about. if you are taking about using sql server query file click on Programs ->management studio -> click on Query Analyzer

if you are taking about running some command line script file..check this

http://www.databasejournal.com/features/mssql/article.php/3654176/SQL-Server-2005-Command-Line-Tool-SQLCMD--Part-I.htm
0
 
LVL 2

Author Comment

by:gracemedia
ID: 24331319
how do you do it through Management Studio?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 8

Expert Comment

by:k_rasuri
ID: 24331444
i dont know what kind of file are you talking about...is this just a sql script. then you can use Query Analyzer.

if you want to do some administration tasks..you can use SQLCMD tool (check the link i pasted earlier)
0
 
LVL 2

Author Comment

by:gracemedia
ID: 24331587
It is a .sql file
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_CuteChat4_SupportAgent_CuteChat4_SupportDepartment]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[CuteChat4_SupportAgent] DROP CONSTRAINT FK_CuteChat4_SupportAgent_CuteChat4_SupportDepartment
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_InstantMessage]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_InstantMessage]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_Lobby]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_Lobby]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_LogEvent]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_LogEvent]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_LogMessage]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_LogMessage]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_Portal]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_Portal]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_Rule]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_Rule]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_Settings]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_Settings]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportAgent]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportAgent]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportCustomer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportCustomer]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportDepartment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportDepartment]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportFeedback]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportFeedback]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportMessage]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportMessage]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_SupportSession]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_SupportSession]
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CuteChat4_User]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CuteChat4_User]
GO
 
CREATE TABLE [dbo].[CuteChat4_InstantMessage] (
	[MessageId] [int] IDENTITY (1, 1) NOT NULL ,
	[MsgTime] [datetime] NOT NULL ,
	[Sender] [nvarchar] (100) NOT NULL ,
	[SenderId] [nvarchar] (100) NOT NULL ,
	[Target] [nvarchar] (100) NOT NULL ,
	[TargetId] [nvarchar] (100) NOT NULL ,
	[Offline] [int] NOT NULL ,
	[DeletedBySender] [int] NULL ,
	[DeletedByTarget] [int] NULL ,
	[IPAddress] [nvarchar] (25) NOT NULL ,
	[Text] [ntext] NULL ,
	[Html] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_Lobby] (
	[LobbyId] [int] IDENTITY (1, 1) NOT NULL ,
	[Title] [nvarchar] (50) NOT NULL ,
	[Topic] [nvarchar] (200) NOT NULL ,
	[Announcement] [ntext] NOT NULL ,
	[Locked] [bit] NOT NULL ,
	[AllowAnonymous] [bit] NOT NULL ,
	[Password] [nvarchar] (50) NOT NULL ,
	[Description] [nvarchar] (400) NOT NULL ,
	[Integration] [nvarchar] (200) NOT NULL ,
	[ManagerList] [ntext] NOT NULL ,
	[MaxOnlineCount] [int] NOT NULL ,
	[MaxIdleMinute] [int] NOT NULL ,
	[AutoAwayMinute] [int] NOT NULL ,
	[HistoryCount] [int] NOT NULL ,
	[HistoryDay] [int] NOT NULL ,
	[SortIndex] [int] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_LogEvent] (
	[EventId] [int] IDENTITY (1, 1) NOT NULL ,
	[EvtTime] [datetime] NOT NULL ,
	[Category] [nvarchar] (50) NOT NULL ,
	[Message] [nvarchar] (3000) NOT NULL ,
	[Portal] [nvarchar] (50) NOT NULL ,
	[Place] [nvarchar] (50) NOT NULL ,
	[UserName] [nvarchar] (50) NULL ,
	[UserId] [nvarchar] (50) NULL 
) ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_LogMessage] (
	[MessageId] [int] IDENTITY (1, 1) NOT NULL ,
	[MsgTime] [datetime] NOT NULL ,
	[Location] [nvarchar] (50) NOT NULL ,
	[Place] [nvarchar] (50) NOT NULL ,
	[Sender] [nvarchar] (100) NULL ,
	[SenderId] [nvarchar] (100) NULL ,
	[Target] [nvarchar] (100) NULL ,
	[TargetId] [nvarchar] (100) NULL ,
	[Whisper] [int] NOT NULL ,
	[IPAddress] [nvarchar] (25) NOT NULL ,
	[Text] [ntext] NULL ,
	[Html] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_Portal] (
	[PortalName] [nvarchar] (50) NOT NULL ,
	[Properties] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_Rule] (
	[RuleId] [int] IDENTITY (1, 1) NOT NULL ,
	[Category] [nvarchar] (50) NOT NULL ,
	[SortIndex] [int] NOT NULL ,
	[RuleMode] [nvarchar] (50) NOT NULL ,
	[Expression] [nvarchar] (50) NOT NULL ,
	[Disabled] [bit] NOT NULL 
) ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_Settings] (
	[SettingName] [nvarchar] (50) NOT NULL ,
	[SettingData] [ntext] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportAgent] (
	[DepartmentId] [int] NOT NULL ,
	[AgentUserId] [nvarchar] (50) NOT NULL 
) ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportCustomer] (
	[CustomerId] [nvarchar] (50) NOT NULL ,
	[CustomerData] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportDepartment] (
	[DepartmentId] [int] IDENTITY (1, 1) NOT NULL ,
	[DepartmentName] [nvarchar] (50) NOT NULL 
) ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportFeedback] (
	[FeedbackId] [int] IDENTITY (1, 1) NOT NULL ,
	[FbTime] [datetime] NOT NULL ,
	[CustomerId] [nvarchar] (100) NULL ,
	[DisplayName] [nvarchar] (100) NULL ,
	[Name] [nvarchar] (100) NOT NULL ,
	[Email] [nvarchar] (100) NOT NULL ,
	[Title] [nvarchar] (200) NOT NULL ,
	[Content] [ntext] NOT NULL ,
	[Comment] [ntext] NULL ,
	[CommentBy] [nvarchar] (100) NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportMessage] (
	[MessageId] [int] IDENTITY (1, 1) NOT NULL ,
	[MsgTime] [datetime] NOT NULL ,
	[SessionId] [int] NOT NULL ,
	[MsgType] [nvarchar] (50) NOT NULL ,
	[Sender] [nvarchar] (100) NULL ,
	[SenderId] [nvarchar] (100) NULL ,
	[Target] [nvarchar] (100) NULL ,
	[TargetId] [nvarchar] (100) NULL ,
	[Text] [ntext] NULL ,
	[Html] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_SupportSession] (
	[SessionId] [int] IDENTITY (1, 1) NOT NULL ,
	[BeginTime] [datetime] NOT NULL ,
	[DepartmentId] [int] NOT NULL ,
	[AgentUserId] [nvarchar] (100) NOT NULL ,
	[CustomerId] [nvarchar] (100) NOT NULL ,
	[DisplayName] [nvarchar] (100) NOT NULL ,
	[ActiveTime] [datetime] NOT NULL ,
	[Email] [nvarchar] (50) NULL ,
	[IPAddress] [nvarchar] (50) NOT NULL ,
	[Culture] [nvarchar] (50) NOT NULL ,
	[Platform] [nvarchar] (50) NOT NULL ,
	[Browser] [nvarchar] (50) NOT NULL ,
	[AgentRating] [int] NOT NULL ,
	[SessionData] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
CREATE TABLE [dbo].[CuteChat4_User] (
	[UserId] [nvarchar] (50) NOT NULL ,
	[DisplayName] [nvarchar] (100) NULL ,
	[Description] [nvarchar] (300) NULL ,
	[BuildinIgnores] [ntext] NULL ,
	[BuildinContacts] [ntext] NULL ,
	[ServerProperties] [ntext] NULL ,
	[PublicProperties] [ntext] NULL ,
	[PrivateProperties] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
 
ALTER TABLE [dbo].[CuteChat4_InstantMessage] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_InstantMessage] PRIMARY KEY  CLUSTERED 
	(
		[MessageId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_Lobby] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_Lobby] PRIMARY KEY  CLUSTERED 
	(
		[LobbyId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_LogEvent] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_LogEvent] PRIMARY KEY  CLUSTERED 
	(
		[EventId] DESC 
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_LogMessage] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_LogMessage] PRIMARY KEY  CLUSTERED 
	(
		[MessageId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_Portal] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_Portal] PRIMARY KEY  CLUSTERED 
	(
		[PortalName]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_Rule] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_Rule] PRIMARY KEY  CLUSTERED 
	(
		[RuleId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_Settings] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_Settings] PRIMARY KEY  CLUSTERED 
	(
		[SettingName]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportAgent] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportAgent] PRIMARY KEY  CLUSTERED 
	(
		[DepartmentId],
		[AgentUserId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportCustomer] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportCustomer] PRIMARY KEY  CLUSTERED 
	(
		[CustomerId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportDepartment] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportDepartment] PRIMARY KEY  CLUSTERED 
	(
		[DepartmentId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportFeedback] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportFeedback] PRIMARY KEY  CLUSTERED 
	(
		[FeedbackId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportMessage] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportMessage] PRIMARY KEY  CLUSTERED 
	(
		[MessageId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportSession] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_SupportSession] PRIMARY KEY  CLUSTERED 
	(
		[SessionId]
	)  ON [PRIMARY] 
GO
 
ALTER TABLE [dbo].[CuteChat4_User] WITH NOCHECK ADD 
	CONSTRAINT [PK_CuteChat4_User] PRIMARY KEY  CLUSTERED 
	(
		[UserId]
	)  ON [PRIMARY] 
GO
 
 CREATE  INDEX [IX_CuteChat4_InstantMessage] ON [dbo].[CuteChat4_InstantMessage]([MsgTime], [Sender], [SenderId], [Target], [TargetId], [Offline], [IPAddress]) ON [PRIMARY]
GO
 
ALTER TABLE [dbo].[CuteChat4_Lobby] ADD 
	CONSTRAINT [DF_CuteChat4_Lobby_AllowAnonymous] DEFAULT (1) FOR [AllowAnonymous],
	CONSTRAINT [DF_CuteChat4_Lobby_Password] DEFAULT ('') FOR [Password],
	CONSTRAINT [DF_CuteChat4_Lobby_Description] DEFAULT (N'') FOR [Description],
	CONSTRAINT [DF_CuteChat4_Lobby_Integration] DEFAULT (N'') FOR [Integration],
	CONSTRAINT [DF_CuteChat4_Lobby_AutoAwayMinute] DEFAULT (5) FOR [AutoAwayMinute]
GO
 
 CREATE  INDEX [IX_CuteChat4_LogEvent] ON [dbo].[CuteChat4_LogEvent]([EvtTime], [Category], [Portal], [Place], [UserName], [UserId]) ON [PRIMARY]
GO
 
ALTER TABLE [dbo].[CuteChat4_LogMessage] ADD 
	CONSTRAINT [DF_CuteChat4_LogMessage_Location] DEFAULT (N'Lobby') FOR [Location]
GO
 
 CREATE  INDEX [IX_CuteChat4_LogMessage] ON [dbo].[CuteChat4_LogMessage]([MsgTime], [Location], [Place]) ON [PRIMARY]
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportSession] ADD 
	CONSTRAINT [DF_CuteChat4_SupportSession_AgentRating] DEFAULT (0) FOR [AgentRating]
GO
 
 CREATE  INDEX [IX_CuteChat4_SupportSession_CustomerId] ON [dbo].[CuteChat4_SupportSession]([CustomerId]) ON [PRIMARY]
GO
 
 CREATE  INDEX [IX_CuteChat4_SupportSession_Query] ON [dbo].[CuteChat4_SupportSession]([BeginTime], [DepartmentId], [AgentUserId], [CustomerId]) ON [PRIMARY]
GO
 
ALTER TABLE [dbo].[CuteChat4_SupportAgent] ADD 
	CONSTRAINT [FK_CuteChat4_SupportAgent_CuteChat4_SupportDepartment] FOREIGN KEY 
	(
		[DepartmentId]
	) REFERENCES [dbo].[CuteChat4_SupportDepartment] (
		[DepartmentId]
	) ON DELETE CASCADE 
GO

Open in new window

0
 
LVL 8

Accepted Solution

by:
k_rasuri earned 500 total points
ID: 24331614

All Programs -> SQL Server Management studio ->

Connect to the server
click on File ->Open -> File -> find the file and open

In the databases select the right database from the dropdown list
0
 
LVL 2

Author Closing Comment

by:gracemedia
ID: 31579237
Thank you for your time.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question