I would like a separate file for each object (table, view, or stored procedure).
Could someone point me in the right direction?
Thanks,
Paul
Seperate File - Use SMO programming using .NET and create it.
I would like a separate file for each object (table, view, or stored procedure).
Could someone point me in the right direction?
Thanks,
Paul
Seperate File - Use SMO programming using .NET and create it.
How does one scriptify all database objects using SQL Server 2005 Express / Server Management Studio Express?
I can see how to scriptify individual objects, but I'm not so keen on doing that for 200+ objects!
Thanks in advance
Dave
davebartlett.net1. Right button on database
2. Select Tasks
3. select Generate Scripts
4. follow the instructions
Madhu
|||Thanks, that saved a lot of time.
Do you know how to script all objects, but generate 1 script file per object?
The Wizard doesn't seem to allow that mode, it seems to put all generated scripts in a single file, which is difficult to navigate through when editing.
|||for that you should apply SP2 ... sp2 have all the feature like in SQL 2000... in "OutPut Option window you have all these features... if it is not there in your machine means, yours is not SP2
Madhu
|||Yes, I've installed SP2 and I can now scriptify each object to a separate file.
This is a great feature, thanks for your help.
How does one scriptify all database objects using SQL Server 2005 Express / Server Management Studio Express?
I can see how to scriptify individual objects, but I'm not so keen on doing that for 200+ objects!
Thanks in advance
Dave
davebartlett.net1. Right button on database
2. Select Tasks
3. select Generate Scripts
4. follow the instructions
Madhu
|||
Thanks, that saved a lot of time.
Do you know how to script all objects, but generate 1 script file per object?
The Wizard doesn't seem to allow that mode, it seems to put all generated scripts in a single file, which is difficult to navigate through when editing.
|||for that you should apply SP2 ... sp2 have all the feature like in SQL 2000... in "OutPut Option window you have all these features... if it is not there in your machine means, yours is not SP2
Madhu
|||Yes, I've installed SP2 and I can now scriptify each object to a separate file.
This is a great feature, thanks for your help.
Hi greenie,
DB Mail objects cannot be scripted via Scripter class. We're looking into adding this functionality in a future release.
|||Thanks - I would certainly appreciate the functionality given the DB Mail configuration can get fairly complex. I guess my workaround will be to query the tables and output to my recovery fileHi greenie,
DB Mail objects cannot be scripted via Scripter class. We're looking into adding this functionality in a future release.
|||Thanks - I would certainly appreciate the functionality given the DB Mail configuration can get fairly complex. I guess my workaround will be to query the tables and output to my recovery filesqlHelp appreciatedgudia97@.yahoo.com (gudia) wrote in message news:<2130f7ff.0407071438.275b76f3@.posting.google.com>...
> How would I, using a sql script, copy permissions assigned to a user
> or a role in one or more databases to another user or a role in their
> respective databases?
> Help appreciated
First of all, I would avoid granting permissions to users, since this
becomes difficult to manage - if you always use roles, then things are
much easier. Even if you have only one user in a role today, at least
you won't have any extra work when you need to add a second one. Also,
you should keep a permissions script for each role, so you know which
permissions are correct, and you can run it for multiple roles.
To solve your issue right now, you could add one role to another, if
that's appropriate. If not, then you can reverse-engineer a
permissions script using a query like this:
select
case protecttype
when 205 then 'grant '
when 206 then 'revoke '
end +
case action
when 26 then ' references '
when 193 then ' select '
when 195 then ' insert '
when 196 then ' delete '
when 197 then ' update '
when 224 then ' execute '
end +
' on ' + object_name(id) + ' to TargetRole '
+ case when protecttype = 204 then ' with grant option' else '' end
from
sysprotects
where
uid = user_id('SourceRole')
See sysprotects in Books Online for more information. Note that this
query doesn't handle SELECT or UPDATE permissions on explicit columns,
but only where the permissions are on the whole table. It also does
not handle statement permissions (CREATE TABLE etc.), but you can
easily write a similar query for that.
Simon|||Simon:
Thanks. This will help as a starting point. I do use roles as oppossed
to users for permissioning.
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Ok, guys this is a weird question.
my boss wants script the database objects in a daily basis.
he is too lazy to do the "tasks -> generate scripts -> select objects -> and click finish."
Is there a way to automate this task?
I appreciate your help.
Scriptio is a good way to learn this; http://weblogs.sqlteam.com/billg/archive/2006/06/13/10208.aspx
thanks,"neo" <second714@.hotmail.com> wrote in message
news:155f8e7d.0311201526.39f956fb@.posting.google.c om...
> Is there any command to script out tables/stored procedures?
> I want to make a process to script out tables every night.
> thanks,
There's no TSQL command to do this, but you can use the SQLDMO interface to
generate the scripts. Although you could do it from a procedure using
sp_OACreate, it would probably be better to write an external script in your
preferred scripting language - VBScript, Perl, etc. - because it will be
much easier to work with the output files.
Simon|||any sample code in perl or VBScript?
Thanks,|||second714@.hotmail.com (neo) wrote in message news:<155f8e7d.0311211101.32d01304@.posting.google.com>...
> any sample code in perl or VBScript?
> Thanks,
Here's a snippet of VBScript (untested) to script all the tables in a
DB - check the docs for the constants available with the Script
method:
Set oSQL = WScript.CreateObject("SQLDMO.SQLServer2")
oSQL.Name = "MyServer"
oSQL.LoginSecure = True
oSQL.Connect
'Script all tables
For Each oTable In oSQL.Databases("MyDatabase").Tables
If Not oTable.SystemObject Then
oTable.Script 4 Or 262144 Or 520093696 Or 131072 Or 2 Or 64,
"C:\OutputFolder\" + oTable.Name + ".sql"
End If
Next
Simon
COMMANDS RAN: This is nothing to script, these commands obtain the current
values for open objects and open indexes.
isql -Usa -Pmanager -SCOP1_DS
execute sp_countmetadata "open objects"
execute sp_countmetadata "open indexes"
go
RESULTS: below are the results, there are 5124 user objects and 2122 user
indexes. I need a way to be able to multiple these numbers by a set value
and then use the new value and reset the user objects and user indexes. The
question is how do I isolate the results for each result so I can run the
calculations below. Here is the calculation I need:
current user objects * 1.05 = new value
current user indexes * 1.1 = new value
There are 5124 user objects in all database(s), requiring 6985 Kbytes of
memory.
The 'open objects' configuration parameter is currently set to 500.
(return status = 0)
There are 2122 user indexes in all database(s), requiring 5902 Kbytes of
memory.
The 'open indexes' configuration parameter is currently set to 5000.
(return status = 0)
SETTING THE NEW VALUES: Once I have the new values, I can set the ojects and
indexes as seen below.
1> execute sp_configure "open objects", 5380
2> execute sp_configure "open indexes", 2334
3> goAre you perhaps running Sybase? In that case, you'll probably get a more
help by asking this question in a Sybase forum (e.g. comp.databases.sybase)
rather than one dedicated to Microsoft SQL Server. We Microsoft SQL Server
DBAs are spoiled and don't need to deal with those config options anymore
:-)
--
Hope this helps.
Dan Guzman
SQL Server MVP
"News East" <Methu969@.yahoo.com> wrote in message
news:bY7Lf.171258$WH.51367@.dukeread01...
> Currently I must manually complete the following commands to set a new
> value for the "open objects" and "open indexes". I need a way script this
> process in a batch file.
> COMMANDS RAN: This is nothing to script, these commands obtain the current
> values for open objects and open indexes.
>
> isql -Usa -Pmanager -SCOP1_DS
> execute sp_countmetadata "open objects"
> execute sp_countmetadata "open indexes"
> go
>
>
> RESULTS: below are the results, there are 5124 user objects and 2122 user
> indexes. I need a way to be able to multiple these numbers by a set value
> and then use the new value and reset the user objects and user indexes.
> The question is how do I isolate the results for each result so I can run
> the calculations below. Here is the calculation I need:
> current user objects * 1.05 = new value
> current user indexes * 1.1 = new value
>
> There are 5124 user objects in all database(s), requiring 6985 Kbytes of
> memory.
> The 'open objects' configuration parameter is currently set to 500.
> (return status = 0)
> There are 2122 user indexes in all database(s), requiring 5902 Kbytes of
> memory.
> The 'open indexes' configuration parameter is currently set to 5000.
> (return status = 0)
>
> SETTING THE NEW VALUES: Once I have the new values, I can set the ojects
> and indexes as seen below.
>
> 1> execute sp_configure "open objects", 5380
> 2> execute sp_configure "open indexes", 2334
> 3> go|||News East (Methu969@.yahoo.com) writes:
> Currently I must manually complete the following commands to set a new
> value for the "open objects" and "open indexes". I need a way script
> this process in a batch file.
I guess that you should be able to read these from syscurconfigs or
sysconfigure. Provided that is, that Sybase has not changed the
location for the configuration parameters since last I saw it, and
that was loooong ago.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
How do I generate a single script for each object - table, view, index, trigger, sp, function etc.... in SQL Server. The script that is generated from SQL Server wizards is in a single file.
I want to have separate file for each of the objects.
In EM, you right-click on the object, select 'all tasks', then 'Generate SQL Script'. I do not have access to Management Studio right now, so this may or may not be much help.
Do you have access to Enterprise Manager? You can run SQL Server 2000 and 2005 side by side, so it may be worthwhile installing if you cannot do this in MS.
Clarity Consulting (http://www.claritycon.com)
|||Well we have the same feature in SQL 2005 but I need one individual file for each object. I do not want the script of say all tables in file. I want this in different files with file name as table name that is getting scripted.
It applies to other objects like procs, funcs, triggers, constraints, FKs etc
|||You might look at Scriptio. I use it to create .sql files off of my db schema. On the 2nd tab I select ONE FILE PER OBJECT. www.sqlteam.com. The only problem I have found is that existing sql files (we re-exporting) can't be read-only.|||Currently, the Generate Script Wizard can only create a single file. We plan to implement file-per-object functionality in SP2.