1,020 questions
4
votes
2
answers
1k
views
Regex to fail if multiple matches found
Take the following regex:
P[0-9]{6}(\s|\.|,)
This is designed to check for a 6 digit number preceded by a "P" within a string - works fine for the most part.
Problem is, we need the to fail if more ...
4
votes
2
answers
10k
views
Proper / title case in t-sql
I'm using SQL 2012 RC0, and looking for a function that can convert a column that holds first and last names into proper/title case. I've had a look around SO but can't seem to find anything, if there ...
4
votes
3
answers
1k
views
SQL Server CLR Int64 to SQLInt64 Specified cast is not valid
I am trying to write a CLR that allows me to run a WMI Query on a SQL Server.
using System;
using System.Data.Sql;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Data....
4
votes
1
answer
4k
views
Can you create a CLR UDT to allow for a shared Table type across databases?
If I had a SQL statement such as this:
CREATE TYPE [dbo].[typeRateLimitVariables] AS TABLE(
[vchColumnName] [varchar](250) NULL,
[decColumnValue] [decimal](25, 10) NULL
)
And ...
4
votes
2
answers
4k
views
Install a CLR for SQL Server Linux edition
I have a C# file that compiles and installs perfectly fine on Windows. I can compile it without error on Linux with mcs using the command:
mcs -reference:System.Data.dll -target:library -out:tests/...
4
votes
1
answer
1k
views
Share assemblies from a single database (simulate GAC) in SQL Server
SQL Server version: 2005
.NET version: 3.5
I'm trying to work with a CLR UDF using the most efficient methods in regards to memory and performance. So it seems that SQL Server comes with pre-loaded ....
4
votes
2
answers
2k
views
What can I do to improve performance of my pure User Defined Function in SQL Server?
I have made a simple, but relatively computationally complex, UDF that queries a rarely changing table. In typical usage this function is called many many times from a WHERE clauses over a very small ...
4
votes
2
answers
2k
views
Issue in asynchronous API calls from SQLCLR
In a nutshell, I need to notify a Web API service from SQL Server asynchronously as and when there are changes in a particular table.
To achieve the above, I have created a SQLCLR stored procedure ...
4
votes
3
answers
916
views
How do I rollback a SQL CLR stored procedure when a user cancels the query?
I'm trying to create a SQL CLR stored procedure that will create a table, pass the table name onto a service which will bulk insert some data into it, display the results of the table, then clean up ...
4
votes
3
answers
10k
views
TSQL - Executing CLR Permission
I got a sql procedure from a CLR (.net Assembly) that when executed returns an error
Msg 6522, Level 16, State 1, Procedure sp_HelloWorld, Line 0
A .NET Framework error occurred during execution of ...
4
votes
1
answer
2k
views
Code first Entity Framework 6.1 Custom Aggregate Function
I have a custom CLR Aggregate function on SQL Server to calculate percentiles. Is it possible to call my custom aggregate function through Entity Framework? How is the mapping configured to allow this?...
4
votes
2
answers
593
views
Referencing Signed Assembly in SQL Server 2008R2
I have a C# .NET 3.5 class library (DLL) that is being used in some SSIS script tasks, so it must be loaded to the GAC, which means it must be signed. I created a key and signed the DLL, and it works ...
4
votes
2
answers
2k
views
sqlFileStream System.ComponentModel.Win32Exception: The request is not supported
I have SQL server express 2008 SP1 on windows 7 (Version 6.1 Build 7601: Service Pack 1) and visual studio 2010.
I am attempting to create a Stored Procedure CLR for inserting a file into a file ...
4
votes
1
answer
565
views
SQLCLR & IronPython
Im feeling crazy and I've decided I would really like to write a User-Defined Function in Python that would run in SQL Server 2008. I am interested in doing this as I have a few thousand lines of PL/...
4
votes
1
answer
230
views
What are the relative merits of writing SQL Server CLR UDTs as `struct` or `class`?
Just about every code sample for SQL Server CLR user-defined types implement the type as a struct. However, Microsoft indicates that creating them as class is also an option, but I can't seem to find ...
4
votes
1
answer
2k
views
How do I deploy a CLR Stored Procedure via the MsBuild command line?
I can deploy a SqlClr project project from Solution Explorer by right clicking it an selecting Deploy. However, I would like a command line version where I can also specify custom ConnectionString.
4
votes
1
answer
1k
views
Memory pressure notification in SQL CLR
Google is not able to tell me if there is an API available inside the SQL CLR to get memory pressure notification.
It is obviously used, since the AppDomain will get unloaded under memory pressure, ...
4
votes
0
answers
321
views
Error deploying Microsoft System CLR Types per SQL Server witch ClickOnce
I'm trying to deploy an application that uses Microsoft ReportViewer 2012 that needs Microsoft® System CLR Types per SQL Server 2012 in order to work but I can't get to install it with ClickOnce.
I ...
4
votes
1
answer
5k
views
.NET Framework execution was aborted. Another query caused the AppDomain db.dbo[runtime].4 to be unloaded
I have a SQL CLR Function (written in c#.net) that I'm trying to debug. I attach visual studio to the sqlserver process and begin stepping through, but it keeps crashing and ending with the following ...
4
votes
1
answer
5k
views
Have table-valued function in T-SQL return table with variable number of columns
Is it possible to have a table-valued function in T-SQL return a table with a variable number of columns?
The column names may simply be 1, 2, …, n.
Right now I have a "string split" function that ...
3
votes
3
answers
22k
views
How do you get the sql server username of the currently executing command in a CLR Trigger?
I know that SqlContext.WindowsIdentity returns the current user that is executing the command (in a CLR trigger), however, this only works for windows authenticated users. How do I get the username if ...
3
votes
2
answers
6k
views
.NET Regex whole string matching [duplicate]
If we take the following patterns: 70000@.* and 970000@.*
the string [email protected]:5060
is returning a match to 70000@.*
I understand why it matches, but I need to modify ...
3
votes
2
answers
4k
views
Call Web API 2 method using c# CLR stored procedure by HTTPClient
I have a WPF application that consumes services of MVC web API 2. Created RestClient wrapper using HTTPClient to call async methods such as PostAsync and GetAsync. For ex my POST method wrapper would ...
3
votes
2
answers
975
views
SQL CROSS APPLY with SQLCLR Table-Valued Function (TVF)
I have a table-valued function built as a SQLCLR function calling a calculation on a remote Web Service. I was wondering if the CROSS APPLY function will call the function in parallel or in a ...
3
votes
2
answers
5k
views
How refresh to refresh C# CLR code (assembly) in SQL Server?
I implemented the "HelloWorld" sample of a CLR stored procedure, and it worked.
I then changed the code, recompiled, and re-ran it, and got the old results, not the new results.
Example Code ...