Quantcast
Channel: .NET Framework inside SQL Server forum
Viewing all 780 articles
Browse latest View live

CLR procedures

$
0
0

why CLR procedure deployment takes so much time , how can i deploy it as fast as i deploy a Tsql procedure.


CLR procedures

$
0
0
deploying CLR procedures take lot of time , is there any way we can reduce the deployment time , it takes 1.28 minutes for even a 50 lines procedure , Please help

How to debug SQL CLR Stored procedure?

$
0
0
Hi,

I have started to work on  SQL CLR project. Within my project few stored procedures are developed using SQL CLR. 
As I am unaware about SQL CLR I am not able to debug the stored procedure. My data base is on another DB Server. I have already gone through number of articles but i failed to debug. 
Please help me to understand how SQL CLR works and how to debug these stored procedures. 

Thanks,
  

C Mahone

Winsock error when running SQL Server Stored Proc

$
0
0

I have a SQL Server stored procedure that is trying to read emails from an IMAP server (I am using mail.dll from www.limilabs.com). The SP works fine on my local computer/db, and the code also runs fine when run from a console application on my remote server. When I try to run it from SQL Server however I get this error message:

Msg 6522, Level 16, State 1, Procedure GetEmails, Line 0A .NET Framework error occurred during execution of user-defined routine or aggregate "GetEmails": Limilabs.Client.ServerException: The requested name is valid, but no data of the requested type was found ---> System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was foundSystem.Net.Sockets.SocketException:    at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)   at System.Net.Sockets.Socket.Connect(String host, Int32 port)   at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL)Limilabs.Client.ServerException:    at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL)   at StoredProcedures.GetEmails()

I suspect it is something to do with permissions (??) but it is beyond my knowledge of SQL Server. Anyone have some pointers? I am using the IP for the IMAP server, I have switched off the firewall.

Thanks


Storing to a static field is not allowed in safe assemblies

$
0
0

When I try to add my C#.Net CLR Assembly WITH PERMISSION_SET=SAFE I get the following error:

CREATE ASSEMBLY failed because method 'my_procedure' on type 'StoredProcedures'
in safe assembly 'MyAssembly' is storing to a static field.
Storing to a static field is not allowed in safe assemblies.

I can't find any documentation on what this means or how to address it.  What is a static field?

Thanks.

Publish SQL CLR Stored Procedure referencing other assembly

$
0
0
Hi All,

I am working on SQL CLR stored procedure. I ahave used reference of another Assembly in project. when i am publishing the project to DB it gives me following error 

"ALTER ASSEMBLY failed because the referenced assemblies would change. The referenced assembly list must remain the same."   

Please help me to understand this error and let me know how can i resolve this.

Thanks,

C Mahone

Database compress from .net code

$
0
0

Hi,

I would like to compress the database in SQL Server 2012.

First I tried with the following SQL queries:

DBCC SHRINKDATABASE(DatabaseName);

GO
ALTER DATABASE DatabaseName SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE (DatabaseName_log, 5)
GO
ALTER DATABASE DatabaseName SET RECOVERY FULL
GO

When I tries to execute the above queries in SQL server directly, it works properly; by executing in Stored procedure as well.

But when I tried to call the stored procedure from .net code, it gives e the exception of {"Cannot perform a shrinkdatabase operation inside a user transaction. Terminate the transaction and reissue the statement."}.

Kindly guide me if there is any problem with the queries, or if there is another solution to Compress the database from .net code.

Thanks.

How I represents a geography data in C#?

$
0
0
How I represents a geography data in C#?

Store Procedure Return field value Changing

$
0
0

Hi ,

Exec sp in sql server return this result


but call store procedure in visual studio cmd.ExecuteReader() but result is different.

True field coming false, Nvarchar field not emtpy but coming empty.

StartInterval coming empty, BlokKapama coming false why?

 Why result is changing call sp?

Have a nice day.



CLR Procedure and returning large number of rows

$
0
0

I have a CLR stored procedure coded in C# that retrieves data from a web service, and returns that data using SendResultsStart/SendResultsRow/SendResultsEnd. This all works fine, except when the data from the web service is tens or even thousands of records. The code itself takes about 3 minutes on average to do all it's work with around 50000-60000 records, but the procedure does not return in SSMS for about another 10-15 minutes, during which time the CPU and memory usage go up significantly.

To rule out any of the CLR code as the culprit, I created a very simple CLR procedure that just loops to return 100000 records with int and nvarchar(256) fields with the current count, and "ABC" followed by the count.  Here is the code:

[Microsoft.SqlServer.Server.SqlProcedure]
public static void ABC()
{
        System.Diagnostics.Stopwatch ExecuteTimer = System.Diagnostics.Stopwatch.StartNew();
        SqlMetaData[] ResultMetaData = new SqlMetaData[2];
        ResultMetaData[0] = new SqlMetaData("count", SqlDbType.Int);
        ResultMetaData[1] = new SqlMetaData("text", SqlDbType.NVarChar, 256);
        SqlContext.Pipe.SendResultsStart(new SqlDataRecord(ResultMetaData));
        for (int x = 0; x < 100000; x++)
        {
            SqlDataRecord ResultItem = new SqlDataRecord(ResultMetaData);
            ResultItem.SetValue(0, x);
            ResultItem.SetValue(1, "ABC" + x.ToString());
            SqlContext.Pipe.SendResultsRow(ResultItem);
        }
        SqlContext.Pipe.SendResultsEnd();
        TimeSpan ExecTime = ExecuteTimer.Elapsed;
        SqlContext.Pipe.Send("Elapsed Time: " + ExecTime.Minutes.ToString() + ":" + ExecTime.Seconds.ToString() + "." + ExecTime.Milliseconds.ToString());
}

I then executed procedure ABC in SSMS, and it took 21 minutes to return.  All of the data rows were visible after just a couple of seconds, but the query continued to run as the CPU and memory went up again.

Is this really how long it should take to return 100000 rows, or am I missing something?  Is there a better approach than using SendResultsStart/SendResultsRow/SendResultsEnd?

I've googled this to death and haven't found anything that helped or even explained why this is.

I would greatly appreciate any suggestions or alternate methods to achieve this faster.

Thanks!

Alex

Error in CLR assembly after migrating to SQL server 2012

$
0
0

We moved to SQL Server 2012 from 2008R2 and I am unable to get the CLR assembly working.  I have read several topics about trustworthy setting and a mismatch dbo SID. I checked the SID and everything looks good and the 2008R2 server works fine with Trustworthy set to OFF.  I'm starting to think it is a .NET issue.  2008R2 works with 2.0 and 2012 uses 4.0 and i'm wondering if just redeploying the assembly will fix the problem.  Any suggestions would be greatly appreciated. 

Msg 10314, Level 16, State 11, Procedure MP_ExportXYToCSV2, Line 41

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65540. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:

System.IO.FileLoadException: Could not load file or assembly 'exporttocsv, Version=1.0.4780.25878, Culture=neutral, PublicKeyToken=f5567e386ca8280d' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)

System.IO.FileLoadException:

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)

   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

   at System.Reflection.Assembly.Load(String assemblyString)


I created project in visual Stidio 2010 using sql server 2008

$
0
0

I created project in visual Studio 2010 using sql server 2008  now I want to copy database file which is located in  C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA ..... Now I want to copy db in my project bin folder but while I try to copy it gives me error though I am sysadministerator plz help if I am not copying correct file  error heading is that 'This action cant be completed because the file is opened in sql server(MSSQLSERVER)'  and file extention is .ldf

Accidentally overwritten a sql database - Recover possible?

$
0
0

Hi there, 

My wife uses a piece of software called salon Iris.

It uses an SQL database to store client info etc.

She accidentally overwrite her original database with a 'practice template' of clients.

This has overwritten her original.

I have no back up.

Can anyone help?

Thanks

Raw pointer access to in-memory tables

$
0
0

Hello, I realize this is quite an odd question, but I was wondering if it's possible to obtain raw pointers to rows stored in an in-memory table introduced in SQL Server 2014.

What I am trying to do is to use AMD Kaveri APU in conjunction with SQL Server 2014. The APU has 500+ shader cores that can perform an operation on a piece of memory in parallel, and since SQL Server 2014 already keeps these tables in memory, I was hoping there is a way to reference these tables directly via pointers that can be used by APU cores (I could create wrapper code in CLR if needed) rather than taking data out of the database and creating in-memory arrays. All data types I am interested in are fixed length (doubles) and tables can be locked in the "read-only" state while read operations take place.

Is it possible to access in-memory tables via raw pointers?


 

Call web service from CLR

$
0
0

Thanks all for suggestions, I have decided to write CLR SP to call web service. I have few question 

a)I am using SQL 2012 and VSTS 12 to write CLR SP  in Database project template. But I don't see any option to add web service reference.Could someone please help me on the same ?  

b) Does it make any difference if web service is Created on Java or dot net ?

Please suggest.


Gaur


Could not load file or assembly 'System.Core'

$
0
0

Hi,

I updated my SQL 2005 box to .Net 3.5 SP1 to meet anti virus requirements and is getting the error below when attempting to call CLR on the database.

Has anyone experienced this? Any help is appreciated.

A .NET Framework error occurred during execution of user-defined routine or aggregate "clr_number_test":
System.TypeInitializationException: The type initializer for 'MyNumber' threw an exception. ---> System.IO.FileLoadException:
Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=axxxxxxxxxxxxx' or one of its
dependencies.
Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)
System.IO.FileLoadException: at MyNumber..caller()
System.TypeInitializationException:


Francis, MCTS: BI 2008, MCITP: BI 2008 Stay Thirsty My Friends

Msg 6586, Level 16, State 1, Line 1

$
0
0

Assembly 'System.Web' could not be installed because existing policy would keep it from being used.

I am getting an error while trying to run this query

CREATE ASSEMBLY
[System.Web] from
'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll' with permission_set = UNSAFE
GO


Musakkhir Sayyed.

How to get hexa decimal code of assembly.

$
0
0

I am creating one assembly through hexadecimal code. I want to know how to convert dll into hexadecimal code using sql query.


Musakkhir Sayyed.

Msg 10301, Level 16, State 1, Line 1

$
0
0

Msg 10301, Level 16, State 1, Line 33
Assembly 'TestAssembly' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.

I am getting an error while trying to run this query.

CREATE ASSEMBLY AQSQLCLRSegmentAssembly
AUTHORIZATION [dbo]
FROM 'd:\TestAssembly.dll'
WITH PERMISSION_SET = SAFE
GO


Musakkhir Sayyed.


How to get Stored Procedure that uses SAP dll librfc32.dll to work in SQL Server?

$
0
0

We have a class that uses sap remote function calls. We use CreateObject("SAP.Functions") to create an SAP object and then do various things with it. Now we wanted to integrate the class in our SQL Server as a stored procedure. However when we try to execute the SP we always get the error message  "System.Exception: Cannot create ActiveX component."

Since the only ActiveX component we are using is the SAP object it seems rather obvious that this is the problem. We have registered the librfc32.dll on the SQL server, which is the dll sap needs for RFCs. We still get the same error message though.

So how can I get the SAP RFC functions to work on SQL server? I know there are other methods of connecting to SAP, but we don't know anything about them and our class is already working flawlessly for any application that doesn't require us to use a stored procedure.

Viewing all 780 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>