Solved

call c# elements from t-sql (SQL Server) code?

Posted on 2013-01-18
8
555 Views
Last Modified: 2013-01-30
inside a SQL Server trigger or other t-sql code, is it possible to call a c# code piece/element to execute?
0
Comment
Question by:25112
  • 4
  • 2
  • 2
8 Comments
 
LVL 15

Assisted Solution

by:navneethegde
navneethegde earned 334 total points
ID: 38793450
Hi!

No (AFAIK), since compiling of C# wont happen insdie SQl Server.

Your better bet would be to create windows service and read datachanges in table and call your required C# function.

Thanks!
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
ID: 38794469
If you enable CLR Integration, then you can execute .NET code within SQL Server. But you have to deploy the code to the server in order to do so. Have a look at:

http://msdn.microsoft.com/en-us/library/ms345136(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/ms254498(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/ms131048.aspx
0
 
LVL 5

Author Comment

by:25112
ID: 38795473
>>Your better bet would be to create windows service and read datachanges in table and call your required C# function.

is that the service broker feature in sql server?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 5

Author Comment

by:25112
ID: 38795476
>>But you have to deploy the code to the server in order to do so.

does that compromise a dedicated sql-server only server?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38795479
What do you mean by "compromise?"
0
 
LVL 15

Accepted Solution

by:
navneethegde earned 334 total points
ID: 38795629
@25112
Microsoft SQL Server is a relational database management system developed by Microsoft. As a database, it is just a software product whose primary function is to store and retrieve data as requested by other software applications,

So it's better leave it to that.

You can think of Solution like
1. Using Notification Server of SQL Server you can write to file on server.
2. Create windows service to read this file and call you C# code within Windows service.

Thanks!
0
 
LVL 5

Author Comment

by:25112
ID: 38819291
>>What do you mean by "compromise?"

sorry for the delay in getting back to you.

by dedicated sql server, i meant that only sql server would exist and most of the memory dedicated to it.. so we wouldn't put too much of other apps/tools on it.
(web server/app server/db server all separated.. that is what i meant by the word compromise)

when you said "you have to deploy the code to the server in order to do so. " i was wondering if you mean to put .net code on the database server.
0
 
LVL 5

Author Comment

by:25112
ID: 38819294
>>
1. Using Notification Server of SQL Server you can write to file on server.
2. Create windows service to read this file and call you C# code within Windows service.
<<
can you please give a link for the above 2 to explore these options.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question