Hello
I wonder if I can generate the "CREATE TABLE" sentence given the name of a table by means of a stored procedure.
Thanks a lot.Hello
I wonder if I can generate the "CREATE TABLE" sentence given the name of a table by means of a stored procedure.
Thanks a lot.
I think you need the Server Management Objects (SMO) to do what you are thinking of. SMO works in SQL 2005. There's an earlier version of it in SQL 2000, but for the life of me, I can't remember the name right now.
Regards,
hmscott|||I imagine you could create one by using Profiler to examine what happens when you right click a table in Enterprise Manager select "All Tasks -> Generate SQL Script -> Preview". Be aware ahead of time, it's not a one-step process...|||This free console app I wrote may be of use to you. it will generate scripts for all objects in any 2000 or 2005 database. open source so you can tweak it if you want. it uses SMO.
I wrote it as a way to easily export the DDL for a database for checkin to a source control system.
http://www.elsasoft.org/tools.htm
hope it's useful to you!|||Thanks a lot!sql
Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts
Friday, March 30, 2012
is there a syntax t-sql for generate sql scripts.
Is there syntaxs t-sql, function or others to generate
sql script of objects (table, view, stored procedure,..)?
I know we can do manualy from right click and then click
generate all scripts ? but can we do it with programming ?
thanks.For most stored procedures (assuming they are <= 8000 characters) you can
use sp_helptext, you can also SELECT ROUTINE_DEFINITION FROM
INFORMATION_SCHEMA.ROUTINES in your script.
For tables, it's a little more complicated, especially if you have
primary/foreign keys, constraints, default values, etc. I think if you're
going about it this way: create the tables, then script them properly, you
should think about doing it the other way around. :-)
"kresna rudy kurniawan" <kresna_rk@.hotmail.com> wrote in message
news:03e901c39c3b$d15a5eb0$a401280a@.phx.gbl...
> Is there syntaxs t-sql, function or others to generate
> sql script of objects (table, view, stored procedure,..)?
> I know we can do manualy from right click and then click
> generate all scripts ? but can we do it with programming ?
> thanks.|||> generate all scripts ? but can we do it with programming ?
Your best bet is SQL-DMO. Though you can invoke SQL-DMO objects and their
Script methods via T-SQL's sp_OAxxx procedures, you are much better off
using a scripting language such as VB or Perl.
Of course, if you like to do it the hard way and like to re-invent the
wheel, you can always query the system tables and construct the scripts
entirely in T-SQL. That won't be pretty though.
--
Linchi Shea
linchi_shea@.NOSPAMml.com
"kresna rudy kurniawan" <kresna_rk@.hotmail.com> wrote in message
news:03e901c39c3b$d15a5eb0$a401280a@.phx.gbl...
> Is there syntaxs t-sql, function or others to generate
> sql script of objects (table, view, stored procedure,..)?
> I know we can do manualy from right click and then click
> generate all scripts ? but can we do it with programming ?
> thanks.
sql script of objects (table, view, stored procedure,..)?
I know we can do manualy from right click and then click
generate all scripts ? but can we do it with programming ?
thanks.For most stored procedures (assuming they are <= 8000 characters) you can
use sp_helptext, you can also SELECT ROUTINE_DEFINITION FROM
INFORMATION_SCHEMA.ROUTINES in your script.
For tables, it's a little more complicated, especially if you have
primary/foreign keys, constraints, default values, etc. I think if you're
going about it this way: create the tables, then script them properly, you
should think about doing it the other way around. :-)
"kresna rudy kurniawan" <kresna_rk@.hotmail.com> wrote in message
news:03e901c39c3b$d15a5eb0$a401280a@.phx.gbl...
> Is there syntaxs t-sql, function or others to generate
> sql script of objects (table, view, stored procedure,..)?
> I know we can do manualy from right click and then click
> generate all scripts ? but can we do it with programming ?
> thanks.|||> generate all scripts ? but can we do it with programming ?
Your best bet is SQL-DMO. Though you can invoke SQL-DMO objects and their
Script methods via T-SQL's sp_OAxxx procedures, you are much better off
using a scripting language such as VB or Perl.
Of course, if you like to do it the hard way and like to re-invent the
wheel, you can always query the system tables and construct the scripts
entirely in T-SQL. That won't be pretty though.
--
Linchi Shea
linchi_shea@.NOSPAMml.com
"kresna rudy kurniawan" <kresna_rk@.hotmail.com> wrote in message
news:03e901c39c3b$d15a5eb0$a401280a@.phx.gbl...
> Is there syntaxs t-sql, function or others to generate
> sql script of objects (table, view, stored procedure,..)?
> I know we can do manualy from right click and then click
> generate all scripts ? but can we do it with programming ?
> thanks.
Monday, March 12, 2012
Is SQL Server 2005 Combatible with VB 6.0?
I need to see if it is compatible and if not what the steps should be for the VB scripts we have in 6.0It 'should' be capable of executing any T-SQL code that you wrote in a VB6 environment.|||
Yes. Nothing has changed that would prevent the code from executing.
However, for performance reasons, you might want to consider upgrading to .net
Adamus
Labels:
combatible,
compatible,
database,
microsoft,
mysql,
oracle,
scripts,
server,
sql,
steps
Subscribe to:
Posts (Atom)