Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » SQL Server » Downloads
 
Add your own
alternative version

Library for scripting SQL Server database objects with examples

, 8 Nov 2011 CPOL
This article is about library for scripting SQL Server database objects and examples representing how this library can be used.
DBCompare_Bin.zip
DBCompare_Bin
DBCompare.exe
DBCompare.pdb
DifferenceEngine.dll
DifferenceEngine.pdb
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.ObjectBuilder2.dll
Microsoft.Practices.Unity.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Management.Sdk.Sfc.dll
Microsoft.SqlServer.Smo.dll
ObjectHelper.dll
ObjectHelper.pdb
DBDocumentation_Bin.zip
DBDocumentation_Bin
DBDocumentation.exe
DBDocumentation.pdb
DBDocumentation.vshost.exe
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.ObjectBuilder2.dll
Microsoft.Practices.Unity.dll
ObjectHelper.dll
ObjectHelper.pdb
Template
document.png
folder-horizontal.png
minus.gif
plus.gif
toggle-small-expand.png
toggle-small.png
toggle-small.png
DBScripter_Src.zip
DBCompare
bin
Debug
Controls
DBCompare.csproj.user
images
IconColumnsFromAllTables.gif
IconTypeAssemblies.gif
IconTypeAsymmetricKeys.gif
IconTypeCertificates.gif
IconTypeContracts.gif
IconTypeDDLTriggers.gif
IconTypeDefaults.gif
IconTypeEventNotifications.gif
IconTypeFullTextCatalogs.gif
IconTypeFunctions.gif
IconTypeMessageTypes.gif
IconTypePartitionFunctions.gif
IconTypePartitionSchemes.gif
IconTypeQueues.gif
IconTypeRoles.gif
IconTypeRoutes.gif
IconTypeRules.gif
IconTypeSchemas.gif
IconTypeServiceBindings.gif
IconTypeServices.gif
IconTypeStoredProcedures.gif
IconTypeSymmetricKeys.gif
IconTypeSynonyms.gif
IconTypeTables.gif
IconTypeUserDefinedTypes.gif
IconTypeUsers.gif
IconTypeViews.gif
IconTypeXMLSchemaCollections.gif
obj
x86
Debug
DBCompare.exe
DBCompare.Login.resources
DBCompare.MDIMain.resources
DBCompare.ObjectCompare.resources
DBCompare.ObjectFetch.resources
DBCompare.pdb
DBCompare.Properties.Resources.resources
DBCompare.ScriptView.resources
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
ResolveAssemblyReference.cache
TempPE
Properties.Resources.Designer.cs.dll
Properties
Settings.settings
Resources
Microsoft.SqlServer.Management.SqlManagerUI.Images.database.ico
Microsoft.SqlServer.Management.SqlMgmt.Images.Stop.ico
Microsoft.SqlServer.Management.UI.dbactive.bmp
Microsoft.SqlServer.Management.UI.VSIntegration.Editors.connect.gif
Misc-Database-3-icon.png
script-gear-icon.png
DBDocumentation
bin
Debug
DBDocumentation.vshost.exe
DBDocumentation.vshost.exe.manifest
DBDocumentation.csproj.user
obj
x86
Debug
DBDocumentation.exe
DBDocumentation.Main.resources
DBDocumentation.pdb
DBDocumentation.Properties.Resources.resources
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
ResolveAssemblyReference.cache
TempPE
Properties.Resources.Designer.cs.dll
Properties
Settings.settings
Resources
Misc-Database-3-icon.png
Template
document.png
folder-horizontal.png
minus.gif
plus.gif
toggle-small-expand.png
toggle-small.png
DBScripter.suo
DifferenceEngine
bin
Debug
DifferenceEngine.csproj.user
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
DifferenceEngine.dll
DifferenceEngine.pdb
TempPE
ObjectHelper
bin
Debug
DBObjectType
obj
ObjectHelper.csproj.user
Debug
DesignTimeResolveAssemblyReferencesInput.cache
ObjectHelper.dll
ObjectHelper.pdb
ResolveAssemblyReference.cache
TempPE
Properties
SQL
using System.Collections.Generic;
using System.Text;
using System;

namespace ObjectHelper.DBObjectType
{
    public class PartitionScheme :BaseDbObject
    {
        public List<string> FileGroups { get; set; }
        public string PartitionFunction { get; set; }
        public int PartitionFunctinoId { get; set; }

        public PartitionScheme()
        {
            FileGroups = new List<string>();
        }

        public string Script()
        {
            var sbScript = new StringBuilder();
            sbScript.Append("CREATE PARTITION SCHEME [" + Name + "]"+Environment.NewLine);
            sbScript.Append("AS PARTITION [" + PartitionFunction + "]" + Environment.NewLine);
            sbScript.Append("TO (");
            for (int i = 0; i < FileGroups.Count; i++)
            {
                sbScript.Append(FileGroups[i]);
                if (i != FileGroups.Count - 1)
                {
                    sbScript.Append(",");
                }
            }
            sbScript.Append(");");
            return sbScript.ToString();
        }
        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kanasz Robert
Architect The Staffing Edge & Marwin Cassovia Soft
Slovakia Slovakia
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
MCSD - Web Applications
MCSE - Data Platform
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
MCSA - SQL Server 2012
MCTS - .NET Framework 3.5, ASP.NET Applications
- SQL Server 2008, Database Development
- SQL Server 2008, Implementation and Maintenance
- .NET Framework 4, Data Access
- .NET Framework 4, Service Communication Applications
- .NET Framework 4, Web Applications
MS - Programming in HTML5 with JavaScript and CSS3 Specialist
 
Open source projects: DBScripter - Library for scripting SQL Server database objects
 

Please, do not forget vote

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 8 Nov 2011
Article Copyright 2011 by Kanasz Robert
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid