Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Run script without management studio

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-04-06 : 09:00:27
I downloaded SQL 2008 express and install database without management studiio.
How to run script to create database including tables and store procedures?

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-06 : 09:22:18
You could do it from Excel or access, using VBA. Here's an example.

Public Sub AddSP()
Dim adoConn As New ADODB.Connection
Dim adoRS As New ADODB.Recordset
Dim sSQL As String

adoConn.Open ("Provider=SQLOLEDB.1;Persist Security Info=True;Initial Catalog=AdventureWorks;Data Source=vm-sql-db01")

sSQL = "CREATE PROCEDURE uspTest AS SELECT * FROM Production.Product"
adoConn.Execute sSQL

Set adoRS.ActiveConnection = adoConn
adoRS.CursorLocation = adUseClient
adoRS.CursorType = adOpenDynamic
adoRS.Open "uspTest"

Debug.Print adoRS.Fields(0).Name, adoRS.RecordCount, adoRS(0)

sSQL = "DROP PROCEDURE uspTest"
adoConn.Execute sSQL
End Sub


There are 10 types of people in the world, those that understand binary, and those that don't.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-06 : 10:54:34
or use the command line tools.

For 2005 it was sqlcmd

(is it still on 2008?)

or download a free front end like Toad
http://toadforsqlserver.com/index.jspa

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-06 : 11:00:24
quote:
Originally posted by Transact Charlie
or download a free front end like Toad
http://toadforsqlserver.com/index.jspa



Oh, I'd forgotten about that. Toad would be a much better idea than using excel (or command line tools). Toad rocks.

There are 10 types of people in the world, those that understand binary, and those that don't.
Go to Top of Page
   

- Advertisement -