Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Thursday, March 29, 2012

Creatng Charts Using scripts in sql server 2005 express

Hi all,

I want to Create charts for database table entries in sql server 2005 express edition, by using the scripts only not through wizards...

Plz help me for the above topic

Thanks & Regards,
Srinivaswhat scripts are you refering to? TSQL?|||Hi,
I just want to prepare the charts with out using wizards..., by using some stored proceduers we can get the data from database and then create the charts with some code( script).., that scripts r in visual studio or any thing ,

give me some idea about that one (or) give me some links related to this topic..

thanking you very much..

regards,
Srinivas|||

Hi,

I really did not understand what you are talking about, but perhaps you are referencing the ReportViewer controls..http://msdn2.microsoft.com/en-us/library/ms251671.aspx

regards

|||

T-SQL only returns data, you will need to use some other program to generate the charts from the data. You could use the Reporting controls in VS but I believe the report designer for VS is only available in VS Pro and as a download for VWD Express. (The other Express products don't have report design as a feature.) You can also consider Report Server, which is part of SQL Express Advanced. You will additionally need the SQL Express Toolkit to get the report design projects as part of BIDS.

Office also provides charting capabilities in both Excel and Access. Just retrieve the data and create your chart. In Office 2003 I found Access to have slightly better charting capabilities because of the use of the Office Web Components, but Excel has better analytical tools if you want to manipulate the data prior to creating your charts.

There are also a number of third-party tools and controls that you should be able to find by searching the web.

Regards,
Mike Wachal

Creation scripts from a database

I would like to know the sql command to generate all the scripts of a database so that I can replicate the same database for testing purpose. For instance, I need those scripts to help me re-create the database itself and indexes, triggers, and stored procedures of it if possible.

I remember there was a command to display all these scripts in Sql but I forgot it. If someone knows it, please help. Thanks in advance.

blumonde

Maybe you can use Enterprise Manager, select the database in EM, right click it, choose 'All tasks'->'Generate Script', click 'Show All'. Then you can choose objects to be scripted, and save the script to file system.|||

If you are in SQL Server 2000 in Query Analyzer in the Object browser with the database closed in Enterprise Manager right click on the database and click on create and you will get the create database statement. If you need the create statement for any object in the database make sure the database is open in Enterprise Manager and do the same per object and you will generate the create statement of all the objects.

In SQL Server 2005 do the same in Management Studio to generate the create statement.

Another way to move database is to use the Backup and Restore wizard and use the restore from device option to recreate the database. If your test SQL Server in not on the network remember to put the .BAK file in the Backup subfolder in Microsoft SQL Server folder in Programs. Hope this helps.

|||

Hi Iori_Jay and Caddre,

Thanks for your help. I have the scripts now. Thanks again. I appreciate it a lot.

blumonde

Thursday, March 22, 2012

Creating tables with SQL Scripts (SOLVED)

In sql server 2003 I would create tables with generated sql scripts.
This way I could easily create duplicate dev environments.

Now in SQL 2005 Dev edition I try to run my scripts to create tables.
I create a db [MSS].
They run successfully but there is no table created.

(example script)USE [MSS]
GO
/****** Object: Table [dbo].[KataNames] Script Date: 08/17/2006 13:28:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[KataNames](
[Kata] [char](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[SequenceId] [int] IDENTITY(1,1) NOT NULL,
[Description] [char](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Style] [char](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Any clue what else I have to do to let these scripts actually create tables or why if they run ok, where is my table ?

Thanks

Kim AllbritainDid you 'Refresh' the table list in SSMS?|||Right click your "Databases" node and choose "Refresh"|||Of course I refreshed the db list. I even restarted the app and looked again. No table, but successful completion of the script every time.

Is it possible to back up a sql 200 db on one machine and restore it to 2005 sql on another?|||

KAllbritain wrote:

Of course I refreshed the db list. I even

restarted the app and looked again. No table, but successful completion

of the script every time.

Is it possible to back up a sql 200 db on one machine and restore it to 2005 sql on another?

There isnt much point saying "Of course I did" we diddnt know that you did "yes I tried that" would have been much nicer

Ok, are you using an application to send these scripts? Like Access or .NET

If so, the application or the user account you are using to fire the scripts may not have the appropriate permissions to do so.

Alternatively, do you mean you fired the script in the Query Analayzer of SQL Server 2005 and still do not see the tables?

Do you have serveral SQL Servers on your network?

AFAIK there is no SQL Server 2003, and with regards to porting a 2000 to 2005 yes its possible, there is some documentation here; http://www.microsoft.com/technet/prodtechnol/sql/themes/default.mspx

take it slow, let us fully understand your situation so that we can resolve it = )|||I appreciate your response.

It was sql2000 dev version using 2003 .Net

on sql2005 dev:

The scripts are loaded into the query analyzer and run from there
while connected to the proper db on my local machine.
There are no other servers presently connected.

The script indicates the proper db as well so How can it report
successful without actually performing the create table?|||

If the purpose of the script is to CREATE an object, it is not successful until after it creates that object. If you want to verify syntax, you could, in SSMS, click on the green 'checkmark' icon on the toolbar, or [Query], [Parse] on the menu, or {ctrl}{F5}.

If you want to verify that it actually works, you could wrap it in a TRANSACTION and ROLLBACK when completed.

Or run it in a 'Test' database first.

|||Thanks

The scripts purpose is create a table. It works in sql2000 fine.
The message provided after executing the script is that it was "Successful", therefore I would expect the object (table) to be created.

I am cloning a small db in a new environment, change from 2000 to 2005.
The syntax is fine.

My problem is that if the syntax is fine, the script works in sql2000,
and SSMS says it worked, why doesn't it?

What else can I do?

I could build the tables by hand but why?|||OK I solved this. Just in case anyone else reads this thread.

The table was created by my scripts alright, just not in the db I thought I was in.

I was looking at db "Library" and it was highlighted, but when I opened the Query screen and connected it defaulted to the (Master)
db, so that's where The tables were.

Would be nice if the IDE for SQl2005 would default to the
db you were actually connected and working on instead of
re-connecting to something else.

But it worked ok.

Bye

Creating tables with SQL Scripts

In sql server 2003 I would create tables with generated sql scripts.
This way I could easily create duplicate dev environments.

Now in SQL 2005 Dev edition I try to run my scripts to create tables.
I create a db [MSS].
They run successfully but there is no table created.

(example script)USE [MSS]
GO
/****** Object: Table [dbo].[KataNames] Script Date: 08/17/2006 13:28:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[KataNames](
[Kata] [char](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[SequenceId] [int] IDENTITY(1,1) NOT NULL,
[Description] [char](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Style] [char](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Any clue what else I have to do to let these scripts actually create tables or why if they run ok, where is my table ?

Thanks

Kim AllbritainDid you 'Refresh' the table list in SSMS?|||Right click your "Databases" node and choose "Refresh"|||Of course I refreshed the db list. I even restarted the app and looked again. No table, but successful completion of the script every time.

Is it possible to back up a sql 200 db on one machine and restore it to 2005 sql on another?|||

KAllbritain wrote:

Of course I refreshed the db list. I even

restarted the app and looked again. No table, but successful completion

of the script every time.

Is it possible to back up a sql 200 db on one machine and restore it to 2005 sql on another?

There isnt much point saying "Of course I did" we diddnt know that you did "yes I tried that" would have been much nicer

Ok, are you using an application to send these scripts? Like Access or .NET

If so, the application or the user account you are using to fire the scripts may not have the appropriate permissions to do so.

Alternatively, do you mean you fired the script in the Query Analayzer of SQL Server 2005 and still do not see the tables?

Do you have serveral SQL Servers on your network?

AFAIK there is no SQL Server 2003, and with regards to porting a 2000 to 2005 yes its possible, there is some documentation here; http://www.microsoft.com/technet/prodtechnol/sql/themes/default.mspx

take it slow, let us fully understand your situation so that we can resolve it = )|||I appreciate your response.

It was sql2000 dev version using 2003 .Net

on sql2005 dev:

The scripts are loaded into the query analyzer and run from there
while connected to the proper db on my local machine.
There are no other servers presently connected.

The script indicates the proper db as well so How can it report
successful without actually performing the create table?|||

If the purpose of the script is to CREATE an object, it is not successful until after it creates that object. If you want to verify syntax, you could, in SSMS, click on the green 'checkmark' icon on the toolbar, or [Query], [Parse] on the menu, or {ctrl}{F5}.

If you want to verify that it actually works, you could wrap it in a TRANSACTION and ROLLBACK when completed.

Or run it in a 'Test' database first.

|||Thanks

The scripts purpose is create a table. It works in sql2000 fine.
The message provided after executing the script is that it was "Successful", therefore I would expect the object (table) to be created.

I am cloning a small db in a new environment, change from 2000 to 2005.
The syntax is fine.

My problem is that if the syntax is fine, the script works in sql2000,
and SSMS says it worked, why doesn't it?

What else can I do?

I could build the tables by hand but why?|||OK I solved this. Just in case anyone else reads this thread.

The table was created by my scripts alright, just not in the db I thought I was in.

I was looking at db "Library" and it was highlighted, but when I opened the Query screen and connected it defaulted to the (Master)
db, so that's where The tables were.

Would be nice if the IDE for SQl2005 would default to the
db you were actually connected and working on instead of
re-connecting to something else.

But it worked ok.

Bye

Monday, March 19, 2012

creating sql script with records

hello!
which program is the besto for creating sql scripts with records from tables
I choose? I mean, if I want to create whole database, but only save records
from 5 tables.
thanks!
> which program is the besto for creating sql scripts with records from
tables
> I choose? I mean, if I want to create whole database, but only save
records
> from 5 tables.
You can script objects and then use DTS or bcp.exe to transfer the data.
Additioanally, you can use a procedure that generates insert statements from
a table. Check for sch a procedure, for example, at
http://www.thecodeproject.com/databa...ratorPack.asp.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
|||It is possible that some of the stuff I've listed here has this feature:
http://www.karaszi.com/SQLServer/inf...ate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Bernard" <bernard@.form.hr> wrote in message news:cklc5l$an$1@.ls219.htnet.hr...
> hello!
> which program is the besto for creating sql scripts with records from tables I choose? I mean, if
> I want to create whole database, but only save records from 5 tables.
> thanks!
>

creating sql script with records

hello!
which program is the besto for creating sql scripts with records from tables
I choose? I mean, if I want to create whole database, but only save records
from 5 tables.
thanks!> which program is the besto for creating sql scripts with records from
tables
> I choose? I mean, if I want to create whole database, but only save
records
> from 5 tables.
You can script objects and then use DTS or bcp.exe to transfer the data.
Additioanally, you can use a procedure that generates insert statements from
a table. Check for sch a procedure, for example, at
http://www.thecodeproject.com/datab...eratorPack.asp.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com|||It is possible that some of the stuff I've listed here has this feature:
http://www.karaszi.com/SQLServer/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Bernard" <bernard@.form.hr> wrote in message news:cklc5l$an$1@.ls219.htnet.hr...en">
> hello!
> which program is the besto for creating sql scripts with records from tabl
es I choose? I mean, if
> I want to create whole database, but only save records from 5 tables.
> thanks!
>

creating sql script with records

hello!
which program is the besto for creating sql scripts with records from tables
I choose? I mean, if I want to create whole database, but only save records
from 5 tables.
thanks!> which program is the besto for creating sql scripts with records from
tables
> I choose? I mean, if I want to create whole database, but only save
records
> from 5 tables.
You can script objects and then use DTS or bcp.exe to transfer the data.
Additioanally, you can use a procedure that generates insert statements from
a table. Check for sch a procedure, for example, at
http://www.thecodeproject.com/database/InsertGeneratorPack.asp.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com|||It is possible that some of the stuff I've listed here has this feature:
http://www.karaszi.com/SQLServer/info_generate_script.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Bernard" <bernard@.form.hr> wrote in message news:cklc5l$an$1@.ls219.htnet.hr...
> hello!
> which program is the besto for creating sql scripts with records from tables I choose? I mean, if
> I want to create whole database, but only save records from 5 tables.
> thanks!
>

Sunday, March 11, 2012

Creating Scripts via Query Analyzer or Enterprise Manager

I'm trying to decide what is the best practice in terms of creating scripts
that, for instance, update an existing database. It seems there are a
couple of ways to do this (although I am sure there are more). It is often
suggested that you code your changes, by hand, using Enterprise Manager. As
I am looking at examples how to do this, I understand some of the basics of
doing this. For instance, if I have a tabled called Numbers and there is a
field named Employee (data type int, length 4, non nullable) that I want to
add a unique constraint to, it seems that most examples have the following
simplistic syntax:
ALTER TABLE Numbers
ADD CONSTRAINT EmployeeUnique
UNIQUE(Employee)
If I make the same change via Enterprise Manager and then click the Save
Change Script button, the amount of code it creates is much more:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
ALTER TABLE dbo.Numbers ADD CONSTRAINT
IX_Numbers UNIQUE NONCLUSTERED
(
Employee
) ON [PRIMARY]
GO
COMMIT
So, is all of this extra code necessary? Are the examples I am looking at
too simplistic? Is it OK to use EM to make changes and then generate the
scripts?
Thanks.It si absolutely Ok to that in QA (the way you did).
All these SET statements, generated by EM, are actually happening whenever
you create a new session in QA, BUT behind the scene. You may see this if
you trace tsql exec from QA by Profiler.
With transactions is the same situation: in case of implicit transactions,
new T-SQL statement starts a new transaction. This explains Begin-commit
blocks inside EM-generated code.
All these settings are server defaults and can be changed.
Regards,
Marko Simic
"epigram" wrote:

> I'm trying to decide what is the best practice in terms of creating script
s
> that, for instance, update an existing database. It seems there are a
> couple of ways to do this (although I am sure there are more). It is ofte
n
> suggested that you code your changes, by hand, using Enterprise Manager.
As
> I am looking at examples how to do this, I understand some of the basics o
f
> doing this. For instance, if I have a tabled called Numbers and there is
a
> field named Employee (data type int, length 4, non nullable) that I want t
o
> add a unique constraint to, it seems that most examples have the following
> simplistic syntax:
> ALTER TABLE Numbers
> ADD CONSTRAINT EmployeeUnique
> UNIQUE(Employee)
> If I make the same change via Enterprise Manager and then click the Save
> Change Script button, the amount of code it creates is much more:
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT
> BEGIN TRANSACTION
> ALTER TABLE dbo.Numbers ADD CONSTRAINT
> IX_Numbers UNIQUE NONCLUSTERED
> (
> Employee
> ) ON [PRIMARY]
> GO
> COMMIT
>
> So, is all of this extra code necessary? Are the examples I am looking at
> too simplistic? Is it OK to use EM to make changes and then generate the
> scripts?
> Thanks.
>
>|||Do you save all your change scripts so you have a complete audit trail of al
l
changes made to your database? How you make the changes is just one part of
database change management. Check out this article on the subject
http://www.innovartis.co.uk/pdf/ In...Mgt.
pdf
This is an article showing an approach to database change managment that
will always work and gives you a complete audit trail on all database change
s
without slowing down the development of the database. It was the foundation
of the software called DB Ghost (http://www.dbghost.com)
How the database is developed (whether you use Query Analyzer, Enterprise
Manager or other third party tools) holds little relevance to the larger
problems of deploying those changes and having a clear picture of what has
changed, when it was changed, who it was changed by - so any problems can b
e
quickly solved in a repeatable and totally auditable manner. This (I believe
)
is the essence of database change management.
Excuse me for ranting, however I find it very frustrating watching the same
mistakes repeated time and again...
"epigram" wrote:

> I'm trying to decide what is the best practice in terms of creating script
s
> that, for instance, update an existing database. It seems there are a
> couple of ways to do this (although I am sure there are more). It is ofte
n
> suggested that you code your changes, by hand, using Enterprise Manager.
As
> I am looking at examples how to do this, I understand some of the basics o
f
> doing this. For instance, if I have a tabled called Numbers and there is
a
> field named Employee (data type int, length 4, non nullable) that I want t
o
> add a unique constraint to, it seems that most examples have the following
> simplistic syntax:
> ALTER TABLE Numbers
> ADD CONSTRAINT EmployeeUnique
> UNIQUE(Employee)
> If I make the same change via Enterprise Manager and then click the Save
> Change Script button, the amount of code it creates is much more:
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT
> BEGIN TRANSACTION
> ALTER TABLE dbo.Numbers ADD CONSTRAINT
> IX_Numbers UNIQUE NONCLUSTERED
> (
> Employee
> ) ON [PRIMARY]
> GO
> COMMIT
>
> So, is all of this extra code necessary? Are the examples I am looking at
> too simplistic? Is it OK to use EM to make changes and then generate the
> scripts?
> Thanks.
>
>

Creating Scripts via Query Analyzer or Enterprise Manager

I'm trying to decide what is the best practice in terms of creating scripts
that, for instance, update an existing database. It seems there are a
couple of ways to do this (although I am sure there are more). It is often
suggested that you code your changes, by hand, using Enterprise Manager. As
I am looking at examples how to do this, I understand some of the basics of
doing this. For instance, if I have a tabled called Numbers and there is a
field named Employee (data type int, length 4, non nullable) that I want to
add a unique constraint to, it seems that most examples have the following
simplistic syntax:
ALTER TABLE Numbers
ADD CONSTRAINT EmployeeUnique
UNIQUE(Employee)
If I make the same change via Enterprise Manager and then click the Save
Change Script button, the amount of code it creates is much more:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
ALTER TABLE dbo.Numbers ADD CONSTRAINT
IX_Numbers UNIQUE NONCLUSTERED
(
Employee
) ON [PRIMARY]
GO
COMMIT
So, is all of this extra code necessary? Are the examples I am looking at
too simplistic? Is it OK to use EM to make changes and then generate the
scripts?
Thanks.
It si absolutely Ok to that in QA (the way you did).
All these SET statements, generated by EM, are actually happening whenever
you create a new session in QA, BUT behind the scene. You may see this if
you trace tsql exec from QA by Profiler.
With transactions is the same situation: in case of implicit transactions,
new T-SQL statement starts a new transaction. This explains Begin-commit
blocks inside EM-generated code.
All these settings are server defaults and can be changed.
Regards,
Marko Simic
"epigram" wrote:

> I'm trying to decide what is the best practice in terms of creating scripts
> that, for instance, update an existing database. It seems there are a
> couple of ways to do this (although I am sure there are more). It is often
> suggested that you code your changes, by hand, using Enterprise Manager. As
> I am looking at examples how to do this, I understand some of the basics of
> doing this. For instance, if I have a tabled called Numbers and there is a
> field named Employee (data type int, length 4, non nullable) that I want to
> add a unique constraint to, it seems that most examples have the following
> simplistic syntax:
> ALTER TABLE Numbers
> ADD CONSTRAINT EmployeeUnique
> UNIQUE(Employee)
> If I make the same change via Enterprise Manager and then click the Save
> Change Script button, the amount of code it creates is much more:
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT
> BEGIN TRANSACTION
> ALTER TABLE dbo.Numbers ADD CONSTRAINT
> IX_Numbers UNIQUE NONCLUSTERED
> (
> Employee
> ) ON [PRIMARY]
> GO
> COMMIT
>
> So, is all of this extra code necessary? Are the examples I am looking at
> too simplistic? Is it OK to use EM to make changes and then generate the
> scripts?
> Thanks.
>
>
|||Do you save all your change scripts so you have a complete audit trail of all
changes made to your database? How you make the changes is just one part of
database change management. Check out this article on the subject
http://www.innovartis.co.uk/pdf/Inno...ange_Mgt. pdf
This is an article showing an approach to database change managment that
will always work and gives you a complete audit trail on all database changes
without slowing down the development of the database. It was the foundation
of the software called DB Ghost (http://www.dbghost.com)
How the database is developed (whether you use Query Analyzer, Enterprise
Manager or other third party tools) holds little relevance to the larger
problems of deploying those changes and having a clear picture of what has
changed, when it was changed, who it was changed by - so any problems can be
quickly solved in a repeatable and totally auditable manner. This (I believe)
is the essence of database change management.
Excuse me for ranting, however I find it very frustrating watching the same
mistakes repeated time and again...
"epigram" wrote:

> I'm trying to decide what is the best practice in terms of creating scripts
> that, for instance, update an existing database. It seems there are a
> couple of ways to do this (although I am sure there are more). It is often
> suggested that you code your changes, by hand, using Enterprise Manager. As
> I am looking at examples how to do this, I understand some of the basics of
> doing this. For instance, if I have a tabled called Numbers and there is a
> field named Employee (data type int, length 4, non nullable) that I want to
> add a unique constraint to, it seems that most examples have the following
> simplistic syntax:
> ALTER TABLE Numbers
> ADD CONSTRAINT EmployeeUnique
> UNIQUE(Employee)
> If I make the same change via Enterprise Manager and then click the Save
> Change Script button, the amount of code it creates is much more:
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT
> BEGIN TRANSACTION
> ALTER TABLE dbo.Numbers ADD CONSTRAINT
> IX_Numbers UNIQUE NONCLUSTERED
> (
> Employee
> ) ON [PRIMARY]
> GO
> COMMIT
>
> So, is all of this extra code necessary? Are the examples I am looking at
> too simplistic? Is it OK to use EM to make changes and then generate the
> scripts?
> Thanks.
>
>

Creating scripts to run on sql 2000

I'm trying to create scripts for tables that I'll be running on sql 2000. Even though I check the option for sql 2000 compatability in the scripting wizard, the script contains code that won't work in sql 2000. Is there a fix? or am I doing something wrong?

thanks.

Rick, could you supply the code that was generated as well as the task you're trying to perform? This way, at the very least, we can help you perform your task. In addition, we can see if it is a bug in Management Studio.

|||What version of the tools are you using? This was a problem with the Beta SSMS Express tools, which should have been fixed in the SP1 release.

Wednesday, March 7, 2012

Creating object in SQL 2000 Server DB

I opened SSMSexpress and attached to my sql 2005 database and automatically created the scripts for creating all the object in a SQL 2000 DB. The objects seem to be created but I did get script messages. Are these messages harmless?
thanks
Milton

Msg 208, Level 16, State 1, Procedure Requestview, Line 3

Invalid object name 'dbo.requests'.

Msg 15135, Level 16, State 1, Procedure sp_validatepropertyinputs, Line 147

Object is invalid. Extended properties are not permitted on 'dbo.Requestview', or the object does not exist.

Msg 15135, Level 16, State 1, Procedure sp_validatepropertyinputs, Line 147

Object is invalid. Extended properties are not permitted on 'dbo.Requestview', or the object does not exist.

Extended Properties are not in 2000 and the question is why do you need them, it is not simple to move database from 2005 to 2000 so check out the long instructions in the thread below. Hope this helps.

http://forums.asp.net/thread/1494094.aspx

|||Not all extended properties are necessary for an database object, for example description for a object is also a kind of extended property. In SQL2000 you can usesp_addextendedproperty system procedure to add extended procedures, and the properties information will be stored in sysproperties system table.

Sunday, February 19, 2012

Creating insert scripts from tables

Hi,

A seemingly simple question: How do I create an Insert script from the data of a selected number of tables in a given database?

(The Insert script has to be part of a deployment phase)

Esben

check whether this helps u

http://vyaskn.tripod.com/code/generate_inserts.txt

http://vyaskn.tripod.com/code.htm#inserts

Madhu

|||

http://vyaskn.tripod.com/code.htm#inserts

Jens K. Suessmeyer.


http://www.sqlserver2005.de

Friday, February 17, 2012

creating diagrams from SQL Scripts

Hi,

i'm in the modeling area of the portuguese post, and i've a doubt.

i've scripts of some DB (that i've exported from SQL Server) that i want to register im my default SQL (local). But when i run the script of creating the DB on my machine, it doesn't create the diagrams.

Is there any way that i've got this ?

thanks,

Jo?o P.

The diagrams are data stored in system tables so they wouldn't be included in the script of the database.

If you have access to the original database, there are some ways to move/import the diagrams but how you do this depends on what version of SQL Server. If you want to do that, please post back the version of SQL Server (is it SQL Server 7.0, 2000, 2005, etc)

-

|||

Thanks,

my version of SQL is 2000.

cheers,

Jo?o Pedro

|||

This article explains how to move diagrams on SQL 2000:

How To Move a Database Diagram

http://support.microsoft.com/kb/320125

-Sue

|||

thanks for the help,

cheers,

jo?o Pedro

Tuesday, February 14, 2012

Creating DB from scripts

I'm using an integration project to recreate a db as needed from all the scripts i've previously generated. I'm encountering an error when the tables get built in the wrong order because of foreign key constraints. Does anyone know of a way to programmatically execute the scripts of sql tables that don't violate the constraints; so after, I can execute the other table create scripts? Any help or guidance in any way would be appreciated.

I think the SMO alias may be better for you, as SMO has at least the ability to generate scripts taking account of dependencies. See the SMO forum here: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=88&SiteID=1

Donald Farmer

|||Thanks. I will take a look.

Creating Database Update Scripts

I created an application based on an existing database, I made a lot of changes to the database, now I need to create scripts in the new database to use to update the old database. For example, I added 15 fields to 1 of the tables. Is there a way to use Tasks -> Generate Scripts to create a script that will check the existance of each column and create it if it does not exist? I tried multiple ways of doing this, but it will only create columns for tables that do not exist in the old database. If a table exists, none of the new columns are added.

I may be going about doing this wrong. The main goal I am tying to accomplish is to get all of the data that is in the old database (It was in use while the new one was being developed so there is a lot of data in the old database that I need to have in the new one) into the new one.

Am I better off creating a blank database, then exporting all of the data from the old database to the new one? Will this create any problems with my Primary Keys (The are all auto-increment Integers)?

The customary method would be to drop the existing table and add a new one with the correct structure, then restore data to it. But if your goal is really just to get the old data into the new database, a DTS job would do this or a simple SQL UPDATE query with the proper WHERE clause should work.

Jeff

|||The most reliable way to move a database is backup the old database and then restore it as the new database with the new name. Hope this helps.|||

The new database has a lot of new fields in it so restoring the backup would not work.

If I export the data, would I be able to import the data into the new database? All of the fields from the old database still exist, and would doing this change the auto increment Integer Primary Keys? and would doing this cause duplicate keys or is the database smart enough to see that they have been used?

|||If you restore the old database you have only the differences to move to the restored database but you can still use DTS to move the old database. In SQL Server IDENTITY is a property and you can drop it and set it with ALTER TABLE. Run a search for IDENTITY all in SQL Server BOL (books online). Hope this helps.

Creating Custom Scripts Problem

When I ran the sp_script_synctran_commands to generate my custom scripts for my Immediate Updating subscriber on the publisher, it appears the script generated that I need to run on the subscriber is being truncated.
What can I do about that?
in QA go to Tools - Options and click on the results tab. Make sure Maximum
characters per column is 8192.
"JLS" <jlshoop@.hotmail.com> wrote in message
news:uK2JrZx5FHA.3188@.TK2MSFTNGP15.phx.gbl...
When I ran the sp_script_synctran_commands to generate my custom scripts for
my Immediate Updating subscriber on the publisher, it appears the script
generated that I need to run on the subscriber is being truncated.
What can I do about that?
|||Thanx that worked!
Jude
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message news:%23Y2FwNz5FHA.2676@.TK2MSFTNGP15.phx.gbl...
in QA go to Tools - Options and click on the results tab. Make sure Maximum
characters per column is 8192.
"JLS" <jlshoop@.hotmail.com> wrote in message
news:uK2JrZx5FHA.3188@.TK2MSFTNGP15.phx.gbl...
When I ran the sp_script_synctran_commands to generate my custom scripts for
my Immediate Updating subscriber on the publisher, it appears the script
generated that I need to run on the subscriber is being truncated.
What can I do about that?