Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 21st, 2006, 03:09 PM
Registered User
 
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Run .sql Script file in MS SQL Server 2000?

Hi Group,

I'm new to Ms SQL Server 2000 world. I already have the script files having extention as .sql with me.

Can anyone help me telling how to run(execute) a script(.sql) file for creating a database along with tables in Microsoft SQL Server 2000.

The script files were downloaded from wrox.com related to the book of Rob Vieira called "Professional SQL Server 2000 Programming".

Awaiting a quick help by some member of the group.

Prethank to all of you.

Aaarkaycee



skbshd
 
Old March 22nd, 2006, 08:29 AM
Authorized User
 
Join Date: Mar 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

I do not find any specific method to run a .sql file that just double click and you execute it. Although you can use the osql utility to execute a file.

To do this -
[1] Create a File (may be any extension)
[2] I take example of file whose content is like this -
------
Use master
go
Select name from sysdatabases
go
-----
[3] You can run this file as input parameter of osql.exe. If you are new to SQL Server, I must tell you that osql.exe path is already set.

In command line, or any other execution method, you can type -
  osql -Usa -Ppassword -i file1.sql

password is your password and file1.sql is the file which we want to execute.

Reply me if this helps. If I did not understand you, tell me the scenario in detail.

Bye!

- Som Dutt



 
Old March 22nd, 2006, 11:07 AM
Registered User
 
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi SomDutt,

thanks a lot for your valuable gauidence on the topic. I tried executing the script using OSQL.EXE without using any parameters. Though it got executed but the database & tables were not created as expected. May be coz it asked me user & password which I don't know & neither I know how to find out them.

At last I could run that script using profiler menu option File -> Open-> SQL Script at last. Though it gave me problems for first 2-3 times & also produced an internal error related to database connection on first line itself. But somehow it created the database & tables.

On excution of above menu command it opens a open file dialog to select the script file. On selection of script file it displays two windows, one shows the contents of the script file in tabular form. The two columns read as EventClass & TextData. And the other window shows the contents of TextData of the first row. When I click ToolBar button Execute one step, it opens a dialog box called Connect to SQL Server which shows a dot in a drop down list box against label reads as sql server & Windows Authentication radio button selected. When I click Ok button of this dialog it shows dialong called Replay SQL Server. When I press Start Button of this dialog then it closes the opened dialog and creates one more window in profiler's screen having a table with same two columns as EventClass & TextData. The first column of row shows Replay Internal Error and the second column shows description as No matching connection to execute this on Will auto-create one. I don't know its meaning & the cause due to which it is created. Then I keep pressing the same toolbar button to execute the entire script step by step.

This is the exact explanation of my problem. Since I'm new to this forum so I face problems to get back to my topic & replies I got from users of this forums. So I request you to post me the solution on my following email-id [email protected]

Tnaks a lot to you once again,

bye

skbshd
 
Old March 23rd, 2006, 05:59 AM
Authorized User
 
Join Date: Mar 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ramakant!

Actually, everything depends upon you installation. If you chose mixed mode installation, you may have sa as User and Password which you provide at the same time. If you have windows authentication mode, you can execute it with -Usa without -P option, but, -i option must be there.

You are using SQL Profiler and SQL Profile is not meant to run queries. SQL Profile is to monitor the server. It traces events and other factors.

If you want to execute SQL commands, you need to follow - Query Analyzer or ISQL/OSQL. Query Analyzer is GUI based that is isqlw.exe. You can use -

 isqlw -Usa -P -i file1.sql


In Query Analyzer, you will find a window with a dot in a combo box (as you wrote). Just press OK button.

In Query Analyzer Menu goto File > Open to open .sql file and then press F5. If you have problems executing query analyzer, ask about that.

I replied you to follow OSQL with -i (input file) switch because, you can use it easily and get to work with your SQL Server database.

I hope you must have got the point. Reply if problem not solved yet.

Bye!

 
Old July 26th, 2009, 02:46 PM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THROUGH QUERY ANALYZER OPEN YOUR SCRIPT IN EDITOR AND CLICK EXECUTE
JUST
HAVE ANICE TIME
 
Old October 12th, 2009, 05:43 AM
Registered User
 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by aarkaycee View Post
Hi Group,

I'm new to Ms SQL Server 2000 world. I already have the script files having extention as .sql with me.

Can anyone help me telling how to run(execute) a script(.sql) file for creating a database along with tables in Microsoft SQL Server 2000.

The script files were downloaded from wrox.com related to the book of Rob Vieira called "Professional SQL Server 2000 Programming".

Awaiting a quick help by some member of the group.

Prethank to all of you.

Aaarkaycee



skbshd


you must install microSoft SQL Server 2005 in your system.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Data In MS SQL SERVER 2000 The Beginner Classic ASP Basics 1 August 14th, 2006 04:59 PM
Save Pictures in MS SQL Server 2000 kudzuconf SQL Server 2000 1 March 15th, 2006 11:10 AM
MS SQL Server 2000 SP3 out-of-the-box ? Sebastiaan SQL Server 2000 1 February 19th, 2006 06:18 PM
Client/server arcitecture In Ms Sql 2000 Israr SQL Server 2000 0 August 17th, 2005 05:37 AM
create script in sql server 2000 minhpx SQL Server 2000 1 February 21st, 2005 12:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.