Questions tagged [sql-variant]

Describes something rather similar to SQL but not actual ANSI-Complient SQL.

43 questions
18
votes
4 answers

Passing parameter of type 'object' in table-valued parameter for sql_variant column

I have a table-valued parameter in SQL Server 2012 defined as: CREATE TYPE [dbo].[TVP] AS TABLE ( [Id] [int] NOT NULL, [FieldName] [nvarchar](100) NOT NULL, [Value] [sql_variant] NOT NULL ) I call it in C# with code that looks roughly…
16
votes
4 answers

Are there any benefits to using sql_variant over varchar in SQL Server?

I currently have a database table setup as follows (EAV - business reasons are valid): Id - int (PK) Key - unique, varchar(15) Value - varchar(1000) This allows me to add in mixed values into my databse as key/value pairs. For example: 1 | 'Some…
myermian
  • 31,823
  • 24
  • 123
  • 215
12
votes
1 answer

How do you properly handle SQL_VARIANT in Entity Framework Core?

It looks like support has recently been added to Entity Framework Core in .NET Core 2.1 (preview) to allow the mapping of SQL_VARIANT columns (https://github.com/aspnet/EntityFrameworkCore/issues/7043). It looks like the way to go about doing this…
Interminable
  • 1,338
  • 3
  • 21
  • 52
6
votes
1 answer

What variant of SQL does MariaDB use?

It's typical for a Relational Database Management System to use a specific variant of SQL. For example, SQL Server uses Transact-SQL aka T-SQL. I understand MariaDB is based on MySQL (the RDBMS), and the SQL variant that MySQL uses is apparently…
Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66
4
votes
1 answer

How can I set column type when using SqlBulkCopy to insert into a sql_variant column

I'm using SqlBulkCopy to insert/update from a .net DataTable object to a SQL Server table that includes a sql_variant column. However SqlBulkCopy insists on storing DateTime values put into that column as sql type 'datetime' when what I need is…
BowserKingKoopa
  • 2,701
  • 3
  • 33
  • 40
4
votes
2 answers

Using sql_variant with Entity Framework 4

My use case is pretty simple. I have a small table with a column like this: dtgTestValue sql_variant not null I created an Entity Framework model (.edmx file), and it skipped over that column saying: The data type 'sql_variant' is not supported;…
Only Bolivian Here
  • 35,719
  • 63
  • 161
  • 257
3
votes
2 answers

trim sql variant

I have column sql variant, which has the following meanings: 100, 150, D1 I'm trying to convert all numbers in the columns into letters (such as D1) according to specific logic in case when. But 150 has spaces and the CASE WHEN doesn't work. Here's…
Asakura
  • 33
  • 4
2
votes
1 answer

Entity Framework sql_variant as primary key

For a project I used EF Core 5.0 to scaffold an existing database. The database has some tables with sql_variant columns as a part of the primary key. The model created the property as an 'object'. Base OnModelCreating of this property: …
YordiVN
  • 41
  • 3
2
votes
1 answer

Mismatch on SQL_variant and DT_WSTR in BIDS Manager

I'm using BIDS to update some data to SQL Server 2008 R2. My source is a varchar and destination table has this column VariantValue as a sql_variant datatype. So I have used a derived column transformation to create a unicode new column with this…
Nade
  • 23
  • 4
2
votes
2 answers

Problem with Entity Framework Model Designer and SQL_Variant datatype

I have a table that has a column with SQL_Variant type and some other columns with types like int, bigint,... When I add this table to edmx file it adds all columns but the SQL_Variant typed column. Is there a bug or I have to do something to add…
mrtaikandi
  • 6,753
  • 16
  • 62
  • 93
1
vote
0 answers

Explicit conversion of data in a Table Valued Parameter from .NET to T-SQL

I need to call a stored procedure from VB.NET that takes a table valued parameter. The table structure has three columns, one of which is an sql_variant. The DataTable I want to pass to this SP has some strings inside the sql_variant column, which…
Andyrooger
  • 6,748
  • 1
  • 43
  • 44
1
vote
5 answers

What is the best way to define a column in SQL server that may contain either an integer or a string?

I have a situation where two objects of the same type have parents of different types. The following pseudo code explains the situation the best: TypeA a1, a2; TypeB b; TypeC c; a1.Parent = b; a2.Parent = c; To complicate things even further TypeB…
mark
  • 59,016
  • 79
  • 296
  • 580
1
vote
2 answers

SQL 2005 - Variant Parameter Question

I am working on a function that will be used by no less than 10 SProc's, and will probably grow once it is ironed out. Problem i am running into is that i do not want to develop a function for each Data Type, which is why the SQL_VARIANT data type…
GoldBishop
  • 2,820
  • 4
  • 47
  • 82
1
vote
1 answer

SQL_VARIANT and DATETIME2

Lets say you have the following table: CREATE TABLE [dbo].[Test] ( [Value] [sql_variant] NOT NULL ) And lets insert some DATETIME2 values: INSERT INTO [dbo].[Test] ( [Value] ) VALUES ( SYSUTCDATETIME() ) Now, lets see the…
Alex I
  • 2,078
  • 3
  • 18
  • 24
1
vote
1 answer

Is there a way in Django to always CAST a specific Field to VARCHAR?

Background Situation Description: I'm creating a Django2 application which use a Microsoft SQL Server as back-end database. This database has several tables (which I cannot manage or change them) containing SQL_VARIANT fields. This fields contains…
1
2 3