Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

How to Get the Scripts for SQL Server Objects Expand / Collapse
Author
Message
Posted Wednesday, March 25, 2009 8:52 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:27 AM
Points: 6,601, Visits: 8,902
ssaari (3/25/2009)
Thank you, Wayne,

I looked at a couple of table scripts and didn't notice anything wrong. What kind of issues did you see if you don't mind?

Scott


The thing I noticed is that the script only gets the first key (of Primary, Foreign or Unique keys)... primary if one is there. If the table has multiple (PK, 2+ FK, etc.) it only gets the PK. If the table doesn't have a PK, and has 2+ FKs, it only gets the first FK.
Indexes, defaults and check constraints looked okay.



Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
Post #683815
Posted Thursday, March 26, 2009 8:27 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 10:42 AM
Points: 413, Visits: 401
I'm interested in seeing how MS gets the data returned by particular views and functions/procedures. In 2000 I needed a view that would return user information from syslogins but without the password column. (the querying account did not have privileges to read the password column.) So I got the source for syslogins and created my own version minus the password column. In this case it worked because I could select from sysxlogins.
Post #684187
Posted Monday, March 30, 2009 2:46 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:55 AM
Points: 6,350, Visits: 13,677
great article. For free source control try Subversion, you can get it at

http://subversion.tigris.org/


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #686530
Posted Wednesday, November 18, 2009 6:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 1:13 PM
Points: 7, Visits: 547
SQLDMO doesn't expose triggers that I can see(via Intellisense on oSQL). How could this script be modified to include the scripting of triggers?
Post #820772
Posted Wednesday, November 18, 2009 8:01 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, August 21, 2013 8:04 AM
Points: 56, Visits: 133
hello,

Take a look at the script (line 187). It uses the SQLDMOScript_Triggers property. This means that when the call to object.script (line 196) is made, the trigger will also be generated inside the TAB file for that table. I often used this option, and I am able to get the triggers that way.

If you need to, the table object exposes a triggers collection which allows you to select each trigger object.

I hope this helps


http://ozkary.blogspot.com
http://og-bit.com
Post #820857
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse