Giter Site home page Giter Site logo

bigvariant's Introduction

BigVariant

A Sql-Clr assembly for Microsoft SQL Server 2008+ that creates a CLR UDT that can store everything that goes in a SQL_Variant and LOB types like NVARCHAR and XML. The assembly is restricted to the SAFE functionality of .NET which allows it to be installed easily into your database.

Installation

Enabling SQLCLR

If you haven't done so already, the first step in using SQLCLR is enabling it on your database. It is disabled by default.

On your Microsoft SQL Server database, execute the following:

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

Now you are ready to start using SQLCLR assemblies.

Installing into an existing SSDT project

The file is a SQLCLR SAFE-compatible assembly. It can be loaded into your database using SSDT.

Create an empty C# library project in Visual Studio, and then add the BigVariant nuget package as a dependency.
This will give you a nuget binding for the file even though SSDT does not support nuget.

Build. This will make nuget fetch your assembly.

Next, use the References folder in your SSDT project.
Add a the reference to both your dummy-library and to the PxtlCa.BigVariant.Core file that is now present in your packages folder thanks to nuget.

Right-click the added assembly and click "properties". In the properties tab, set the following options to true:

  • Generate SQL Script = true
  • Is Visible = true
  • Model Aware = true

Installing from SSDT when you do not use SSDT to manage your database

Pull the project from http://github.com/Pxtl/BigVariant and open BigVariant.sln.

Right-click PxtlCa.BigVariant.PublishDatabase and select publish.

Configure the publisher to connect to your database and click publish.

Installing from SQL scripts

A SqlCmd script "SqlVariant.Install.SqlCmd.sql" can be downloaded and run (in SqlCmd mode) against your database to install BigVariant.
Just change the Database variable to the name of your database and run it against your DB server (again, in SqlCmd mode) and you'll have BigVariant installed.

If you use the SqlCmd script, you don't need to download any other source.
Note that this can only be done for one-time installs, incremental updates will require DACPACs or SSDT.

If you'd like to install through sqlcmd from the command line, execute

	sqlcmd -S[MyServerName] -v DatabaseName="MyDatabaseName" -i "BigVariant.Install.SqlCmd.sql"

in the folder.

Installing via DACPAC

DACPACs for publishing have not been set up as part of the standard build-process yet.

Usage

See the generated XmlDoc file.

On PxtlCa.pfx

The assembly is signed with my personal key in Release mode, but I (MZ) am keeping my PFX file private.
There's a public snk file for signing in debug mode.
As such, you can build the project in Debug mode or generate your own key for signing in Release mode (or use the public SNK) but you may have to edit the .vcproj file since there are some hand-tweaks to make it choose based on build profile. Pull-requests to make the workflow for this problem sane are always welcome.

bigvariant's People

Contributors

pxtl avatar

Stargazers

 avatar John Zabroski avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

devsw

bigvariant's Issues

BigVariant.AsVariant does not have sane equality behavior.

One of the unit tests fails - comparison of the AsVariant objects fails, which is not SQL behavior.

That is,

declare @bigintVar as BigVariant = dbo.BigVariantFromVariant(CONVERT(bigint, 1))
declare @floatVar as BigVariant = dbo.BigVariantFromVariant(CONVERT(float(24), 1))
select iif(@bigintVar.AsVariant = @floatVar.AsVariant, 'true', 'false')

yields "false"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.