473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What is the correct way to do this?

I have created a SQL Server Express db in my ASP.Net website. I have a
file that contains several SQL statements to create tables (100+) and
stored procedures. I am guessing that there has to be a way of creating
the database tables and stored procedures from the file with SQL
statements (other than typing the statements manually - which would take
hours - and is also error prone). However, I ahve not been able to find
any information that shows how I can use the SQL statements in my file
to generate the tables and stored procedures in my db. Does anyone know
how to do this?. Ideally, I will have the .sql file in the WebSite
project so that whenever I change the schema or a stored procedure, I
can automatically rebuild the db (i.e. update the db) to reflect the new
changes.

So what I need to know is the ff:

1). How can I use my SQL statements file to create tables and stored
procs in my newly created db?
2). How can I keep the db synchronised with any changes in the *.sql
file (i.e. if I change a stored procedure etc, how can I "update the db
with the change?)
Jul 9 '07 #1
3 1223
If you create a correct script (a set of batched TSQL commands separated by
"GO"), you can execute it with SQLCMD or from your own code. I include an
example of an in-process SQLCMD class in my SQLCe EBook but it's not that
hard to launch SQLCMD. This batch can perform any DDL (or DML) operations
needed. AFA maintenance, you'll want to read up on managing databases and
updating schema and procedures in place. There are a number of issues to
consider...

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Grey Alien" <gr**@andromeda.comwrote in message
news:wL*********************@bt.com...
>I have created a SQL Server Express db in my ASP.Net website. I have a file
that contains several SQL statements to create tables (100+) and stored
procedures. I am guessing that there has to be a way of creating the
database tables and stored procedures from the file with SQL statements
(other than typing the statements manually - which would take hours - and
is also error prone). However, I ahve not been able to find any information
that shows how I can use the SQL statements in my file to generate the
tables and stored procedures in my db. Does anyone know how to do this?.
Ideally, I will have the .sql file in the WebSite project so that whenever
I change the schema or a stored procedure, I can automatically rebuild the
db (i.e. update the db) to reflect the new changes.

So what I need to know is the ff:

1). How can I use my SQL statements file to create tables and stored procs
in my newly created db?
2). How can I keep the db synchronised with any changes in the *.sql file
(i.e. if I change a stored procedure etc, how can I "update the db with
the change?)

Jul 9 '07 #2
it depends.

if you have sql2005 dev, then you can use sqlcmd.exe to run the scripts
or use sql work bench.

if you have team suite for databases, then create a database project. it
will create scripts to update prod to dev. (just hit deploy).

if you have none of the above you need to write a program.
-- bruce (sqlwork.com)
Grey Alien wrote:
I have created a SQL Server Express db in my ASP.Net website. I have a
file that contains several SQL statements to create tables (100+) and
stored procedures. I am guessing that there has to be a way of creating
the database tables and stored procedures from the file with SQL
statements (other than typing the statements manually - which would take
hours - and is also error prone). However, I ahve not been able to find
any information that shows how I can use the SQL statements in my file
to generate the tables and stored procedures in my db. Does anyone know
how to do this?. Ideally, I will have the .sql file in the WebSite
project so that whenever I change the schema or a stored procedure, I
can automatically rebuild the db (i.e. update the db) to reflect the new
changes.

So what I need to know is the ff:

1). How can I use my SQL statements file to create tables and stored
procs in my newly created db?
2). How can I keep the db synchronised with any changes in the *.sql
file (i.e. if I change a stored procedure etc, how can I "update the db
with the change?)
Jul 9 '07 #3
To keep the DB synchronized with your latest changes, you can declare
your procedures as follows. Every time the script runs, your
procedures will be re-installed.

IF EXISTS(SELECT * FROM sysobjects WHERE xtype = 'P' AND [name] =
'MyProc')
DROP PROCEDURE MyProc
GO
CREATE PROCEDURE MyProc
AS
-- Implement procedure here
GO

Cheers,
Chris

On Jul 10, 9:06 am, bruce barker <nos...@nospam.comwrote:
it depends.

if you have sql2005 dev, then you can use sqlcmd.exe to run the scripts
or use sql work bench.

if you have team suite for databases, then create a database project. it
will create scripts to update prod to dev. (just hit deploy).

if you have none of the above you need to write a program.

-- bruce (sqlwork.com)

Grey Alien wrote:
I have created a SQL Server Express db in my ASP.Net website. I have a
file that contains several SQL statements to create tables (100+) and
stored procedures. I am guessing that there has to be a way of creating
the database tables and stored procedures from the file with SQL
statements (other than typing the statements manually - which would take
hours - and is also error prone). However, I ahve not been able to find
any information that shows how I can use the SQL statements in my file
to generate the tables and stored procedures in my db. Does anyone know
how to do this?. Ideally, I will have the .sql file in the WebSite
project so that whenever I change the schema or a stored procedure, I
can automatically rebuild the db (i.e. update the db) to reflect the new
changes.
So what I need to know is the ff:
1). How can I use my SQL statements file to create tables and stored
procs in my newly created db?
2). How can I keep the db synchronised with any changes in the *.sql
file (i.e. if I change a stored procedure etc, how can I "update the db
with the change?)

Jul 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
6
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http...
145
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in...
7
by: Aguilar, James | last post by:
Hello all, To begin, yes, this -is- a homework assignment. However, it is for my Algorithms class, and my instructor has given us explicit permission to use "expert" groups like newsgroups, so...
1
by: Naga | last post by:
Hello, Thanks for the response Oleg. Now I need to know few answers. How do I get the value of a node using the xpath. I want the value of the MessageID and ResultCode from secondxml. And using...
6
by: Mark Broadbent | last post by:
this might sound like an obvious question but I have found that usually these two evolve at the same time. One of the biggest reasons for creating the abstraction in the first place (in my...
4
by: **Developer** | last post by:
I looked at MSDN and a book and both described the naming convention for parameters should be camel style. The book used camel, except for Set (ByVal Value as ...) There it always used an...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
8
by: nytimescnn | last post by:
I've read some discuession about lock() for thread-safe. I am wondering what will be the differce between below two code segment? Code 1: class A { private static Object padlock = new...
10
by: onetruelove | last post by:
I want to creat a post like this blog: http://onlinetoefltest.blogspot.com/2007/08/level-c-lesson-1.html When you chose all the answers and click show answer a msg box will appear and tells how...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.