Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Monday, March 19, 2012

CLR User-defined aggregate support Java/J#?

I want to write a Java User-defined aggregate (UDA). Shall I use J#?

I converted the C# example given in books online to J#. I am getting this error (as well as whole bunch of warning when I create the assembly.)

Msg 6558, Level 16, State 1, Line 1

CREATE AGGREGATE failed because type 'Concatenate' does not conform to UDAGG specification due to method 'Init'.

Msg 6597, Level 16, State 2, Line 1

CREATE AGGREGATE failed.

btw, I have the use unsafe assembly options when creating the assembly otherwise I get this error:

Msg 6265, Level 16, State 1, Line 1

CREATE ASSEMBLY failed because type "com.ms.vjsharp.cor.COMUtils" in safe assembly "vjscor" has a pinvokeimpl method. P/Invoke is not allowed in safe assemblies.

Warning: The Microsoft .Net frameworks assembly 'vjscor, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment.

From the warning, I can tell the J# UDA is not tested.

Can someone confirm whether J# UDA is supported or not?

Thanks!

-

Here is my code:

ALTER DATABASE MEDIO set TRUSTWORTHY ON

CREATE ASSEMBLY MyAgg FROM 'C:\code\console\PriceUDA\obj\Debug\PriceUDA.dll' WITH PERMISSION_SET = unsafe

CREATE AGGREGATE MyAgg (@.input nvarchar(200)) RETURNS nvarchar(max) EXTERNAL NAME MyAgg.Concatenate

GO

import System.*;

import System.Data.*;

import Microsoft.SqlServer.Server.*;

import System.Data.SqlTypes.*;

import System.IO.*;

import System.Text.*;

/** @.attribute Serializable() */

/** @.attribute SqlUserDefinedAggregate(

Format.UserDefined, //use clr serialization to serialize the intermediate result

IsInvariantToNulls = true, //optimizer property

IsInvariantToDuplicates = false, //optimizer property

IsInvariantToOrder = false, //optimizer property

MaxByteSize = 8000) //maximum size in bytes of persisted value

*/

public class Concatenate implements IBinarySerialize

{

/// <summary>

/// The variable that holds the intermediate result of the concatenation

/// </summary>

private StringBuilder intermediateResult;

/// <summary>

/// Initialize the internal data structures

/// </summary>

public void Init()

{

this.intermediateResult = new StringBuilder();

}

/// <summary>

/// Accumulate the next value, not if the value is null

/// </summary>

/// <param name="value"></param>

public void Accumulate(SqlString value)

{

if (value.get_IsNull())

{

return;

}

this.intermediateResult.Append(value.get_Value()).Append(',');

}

/// <summary>

/// Merge the partially computed aggregate with this aggregate.

/// </summary>

/// <param name="other"></param>

public void Merge(Concatenate other)

{

this.intermediateResult.Append(other.intermediateResult);

}

/// <summary>

/// Called at the end of aggregation, to return the results of the aggregation.

/// </summary>

/// <returns></returns>

public SqlString Terminate()

{

String output = String.Empty;

//delete the trailing comma, if any

if (this.intermediateResult != null

&& this.intermediateResult.get_Length() > 0)

{

output = this.intermediateResult.ToString(0, this.intermediateResult.get_Length() - 1);

}

return new SqlString(output);

}

public void Read(BinaryReader r)

{

intermediateResult = new StringBuilder(r.ReadString());

}

public void Write(BinaryWriter w)

{

w.Write(this.intermediateResult.ToString());

}

}

No responses... Has anyone else been able to get this to work?|||

Hi Chang!

In SQL Server 2005 we support C#, Visual Basic and managed C++ with SQL CLR.

We haven't tested integration with other languages. However, I can imagine that other languages' vendors have tested their languages with SQL CLR, or are going to do this. In this case, they may have published their recommendations on how to use their languages' features with SQL CLR, what problems you may have and so on.

I'm not aware of such recommendations for J#.

|||Vadim -- We are asking about Microsoft J#, not some 3rd party tool.

Microsoft Visual J# is a .net language that uses the CLR. I've seen dozens of quotes that say it 'should work', but I have yet to find anybody who actually got it to work.

I have a bunch of database-neutral java stored procedures, that I recently ported to work with mssql, that I now need to implement as CLR stored procedures. I'd *really* like to port my java to j# using .net, as opposed to porting to c# (Yes, I know about JLCA, I'm working my way throught that now). Unfortunately, Visual Studio 2005 in J# mode has no support for SQL Server, and every document I find on the internet only talks about using VS to generate SQL code. So far, I have not found 1 single example that shows J# running as a CLR stored proc, or what you might have to do to get it to work.|||

Hi!

You are right; I should have phrased this better. Anyway, due to a variety of reasons we haven’t put significant effort into supporting J#. According to my knowledge, you have chances that functions and procedures will work, but you most probably will have problems with user-defined types and aggregates. Have you tried to wrap your J# logic into, say, C# aggregate?

The fact that a language is a .NET language doesn’t automatically mean that it will go well with SQL CLR. The reason is that SQL CLR puts additional restrictions and requirements to the IL code, compared to those necessary just to run IL executable. Not all code generated by .NET compilers satisfies them, not all run-time libraries of these languages satisfy them. I’d guess the way J# compiles classes is not compliant with SQL CLR.

|||

I can't recall the exact problems off the top of my head, but I do recall there being problems with J# in SQL CLR. You may be able to get this working if you register the assembly as UNSAFEan unfortunate move.

I'll see if I can dredge up more.

Cheers,

-Isaac

CLR User-defined aggregate support Java/J#?

I want to write a Java User-defined aggregate (UDA). Shall I use J#?

I converted the C# example given in books online to J#. I am getting this error (as well as whole bunch of warning when I create the assembly.)

Msg 6558, Level 16, State 1, Line 1

CREATE AGGREGATE failed because type 'Concatenate' does not conform to UDAGG specification due to method 'Init'.

Msg 6597, Level 16, State 2, Line 1

CREATE AGGREGATE failed.

btw, I have the use unsafe assembly options when creating the assembly otherwise I get this error:

Msg 6265, Level 16, State 1, Line 1

CREATE ASSEMBLY failed because type "com.ms.vjsharp.cor.COMUtils" in safe assembly "vjscor" has a pinvokeimpl method. P/Invoke is not allowed in safe assemblies.

Warning: The Microsoft .Net frameworks assembly 'vjscor, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment.

From the warning, I can tell the J# UDA is not tested.

Can someone confirm whether J# UDA is supported or not?

Thanks!

-

Here is my code:

ALTER DATABASE MEDIO set TRUSTWORTHY ON

CREATE ASSEMBLY MyAgg FROM 'C:\code\console\PriceUDA\obj\Debug\PriceUDA.dll' WITH PERMISSION_SET = unsafe

CREATE AGGREGATE MyAgg (@.input nvarchar(200)) RETURNS nvarchar(max) EXTERNAL NAME MyAgg.Concatenate

GO

import System.*;

import System.Data.*;

import Microsoft.SqlServer.Server.*;

import System.Data.SqlTypes.*;

import System.IO.*;

import System.Text.*;

/** @.attribute Serializable() */

/** @.attribute SqlUserDefinedAggregate(

Format.UserDefined, //use clr serialization to serialize the intermediate result

IsInvariantToNulls = true, //optimizer property

IsInvariantToDuplicates = false, //optimizer property

IsInvariantToOrder = false, //optimizer property

MaxByteSize = 8000) //maximum size in bytes of persisted value

*/

public class Concatenate implements IBinarySerialize

{

/// <summary>

/// The variable that holds the intermediate result of the concatenation

/// </summary>

private StringBuilder intermediateResult;

/// <summary>

/// Initialize the internal data structures

/// </summary>

public void Init()

{

this.intermediateResult = new StringBuilder();

}

/// <summary>

/// Accumulate the next value, not if the value is null

/// </summary>

/// <param name="value"></param>

public void Accumulate(SqlString value)

{

if (value.get_IsNull())

{

return;

}

this.intermediateResult.Append(value.get_Value()).Append(',');

}

/// <summary>

/// Merge the partially computed aggregate with this aggregate.

/// </summary>

/// <param name="other"></param>

public void Merge(Concatenate other)

{

this.intermediateResult.Append(other.intermediateResult);

}

/// <summary>

/// Called at the end of aggregation, to return the results of the aggregation.

/// </summary>

/// <returns></returns>

public SqlString Terminate()

{

String output = String.Empty;

//delete the trailing comma, if any

if (this.intermediateResult != null

&& this.intermediateResult.get_Length() > 0)

{

output = this.intermediateResult.ToString(0, this.intermediateResult.get_Length() - 1);

}

return new SqlString(output);

}

public void Read(BinaryReader r)

{

intermediateResult = new StringBuilder(r.ReadString());

}

public void Write(BinaryWriter w)

{

w.Write(this.intermediateResult.ToString());

}

}

No responses... Has anyone else been able to get this to work?
|||

Hi Chang!

In SQL Server 2005 we support C#, Visual Basic and managed C++ with SQL CLR.

We haven't tested integration with other languages. However, I can imagine that other languages' vendors have tested their languages with SQL CLR, or are going to do this. In this case, they may have published their recommendations on how to use their languages' features with SQL CLR, what problems you may have and so on.

I'm not aware of such recommendations for J#.

|||Vadim -- We are asking about Microsoft J#, not some 3rd party tool.

Microsoft Visual J# is a .net language that uses the CLR. I've seen dozens of quotes that say it 'should work', but I have yet to find anybody who actually got it to work.

I have a bunch of database-neutral java stored procedures, that I recently ported to work with mssql, that I now need to implement as CLR stored procedures. I'd *really* like to port my java to j# using .net, as opposed to porting to c# (Yes, I know about JLCA, I'm working my way throught that now). Unfortunately, Visual Studio 2005 in J# mode has no support for SQL Server, and every document I find on the internet only talks about using VS to generate SQL code. So far, I have not found 1 single example that shows J# running as a CLR stored proc, or what you might have to do to get it to work.

|||

Hi!

You are right; I should have phrased this better. Anyway, due to a variety of reasons we haven’t put significant effort into supporting J#. According to my knowledge, you have chances that functions and procedures will work, but you most probably will have problems with user-defined types and aggregates. Have you tried to wrap your J# logic into, say, C# aggregate?

The fact that a language is a .NET language doesn’t automatically mean that it will go well with SQL CLR. The reason is that SQL CLR puts additional restrictions and requirements to the IL code, compared to those necessary just to run IL executable. Not all code generated by .NET compilers satisfies them, not all run-time libraries of these languages satisfy them. I’d guess the way J# compiles classes is not compliant with SQL CLR.

|||

I can't recall the exact problems off the top of my head, but I do recall there being problems with J# in SQL CLR. You may be able to get this working if you register the assembly as UNSAFEan unfortunate move.

I'll see if I can dredge up more.

Cheers,

-Isaac

CLR Trigger to write file.......

Hello, theres,

I have a request to write to a file whenever new record added to the table.

When records insert row by row, it goes well. but when more than 2 session insert at the same time, sometimes it duplicate some record in the file. I try to add synchonize code ( like lock , Monitor) but it doesn't work. any idea ?

Regards,

Agi

I assume you are using this to generate an Audit log or something similar. Here is the route I took.

http://sqljunkies.com/Article/4CD01686-5178-490C-A90A-5AEEF5E35915.scuk

|||

Jonathan,

Thanks for your reply, I just want to write everything to the flat file whenever new record inserted to my table. I write a trigger using c#. I just wonder if more than 2 threads (sessions) insert new record at the same time, what will be write to the flat file ?

Regards,

Agi

|||Hi,
I think the “CLR Triggers for SQL Server 2005” article on
http://aspalliance.com/1273_CLR_Triggers_for_SQL_Server_2005.all
may be helpful in this discussion.

This popular white paper is written by a software engineer from our organization Mindfire Solutions (http://www.mindfiresolutions.com).

I hope you find it useful!

Cheers,
Byapti

CLR trigger on another schema

Hi,

I'm trying to write a clr trigger. I have a table under a user defined schema, say Myschema.Table1. If I write something like this

[SqlTrigger(Name = "Trigger1", Target = "Myschema.Table1", Event = "FOR INSERT")]
I got this error when deploying my assembly on SQl server:
Cannot find the object "Myschema.Table1" because it does not exist or you do not have permissions

If I move Table1 in the dbo schema the assembly is deployed succesfully
Can someone help me

Thank you

This is a known bug. You will need to manually deploy the trigger to the non-dbo schema.

Sunday, March 11, 2012

CLR trigger in another schema

Hi,

I'm trying to write a clr trigger. I have created Myschema schema under schemas folder and Table1 under this schema (i.e.: Myschema.Table1).
I created a clr trigger and tagged it with the Sqltrigger attribute as shown here:

[SqlTrigger(Name = "Trigger1", Target = "Myschema.Table1", Event = "FOR INSERT")]

When I try to deploy my assembly from VS 2005 I got the following error:
Cannot find the object "Myschema.Table1" because it does not exist or you do not have permissions

If I move Table1 in the dbo schema the assembly is deployed succesfully

If I add the assembly from the Assemblies folder in sql2005 db, it deploys successfully. then I can define a trigger using this code

CREATE TRIGGER [SampleTrigger] ON [Myschema].[Table1] AFTER INSERT AS

EXTERNAL NAME [CM.Library.Blocks.SecurityEngine.SQL.Functions].[Triggers].[SampleTrigger]

In this manner, the trigger fires successfully but I'm not able to debug it from VS 2005

Can someone help me? Thanks

Thank you

Ugh... that's sad. :( Maybe Niels Berglund's MSBUILD task can help with this: http://www.sqljunkies.com/WebLog/nielsb/archive/2005/05/03/13379.aspx -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Haplo_69@.discussions.microsoft.com> wrote in message news:95f705e6-a736-44ba-8f20-41cc0d5843cd@.discussions.microsoft.com...Hi,I'm trying to write a clr trigger. I have created Myschema schema under schemas folder and Table1 under this schema (i.e.: Myschema.Table1). I created a clr trigger and tagged it with the Sqltrigger attribute as shown here: [SqlTrigger(Name = "Trigger1", Target = "Myschema.Table1", Event = "FOR INSERT")] When I try to deploy my assembly from VS 2005 I got the following error:Cannot find the object "Myschema.Table1" because it does not exist or you do not have permissionsIf I move Table1 in the dbo schema the assembly is deployed succesfullyIf I add the assembly from the Assemblies folder in sql2005 db, it deploys successfully. then I can define a trigger using this codeCREATE TRIGGER [SampleTrigger] ON [Myschema].[Table1] AFTER INSERT AS EXTERNAL NAME [CM.Library.Blocks.SecurityEngine.SQL.Functions].[Triggers].[SampleTrigger] In this manner, the trigger fires successfully but I'm not able to debug it from VS 2005Can someone help me? ThanksThank you|||

This is a known bug in Visual Studio that was postponed to a later release. You can submit a comment/vote on it here: http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=3732fb5d-55b0-4888-a101-090360681c38

There is a pretty easy workaround however to drop/create the trigger yourself to the schema you want using predeployscript.sql and postdeployscript.sql in your Visual Studio Project. This also lets you use SQLCLR debugging from VS.

|||Thanks. Can you supply me an example of postdeploy e predeploy scripts? What should I write in the SQLTrigger attribute? Or should I comment out this attribute?

|||Ok. Here is the solution. Comment the SqlTrigger Attribute. Write the following postdeployscript.sql

USE [TestSQL2k5]

GO

CREATE TRIGGER [Trigger1] ON [MySchema].[Table1] AFTER INSERT AS

EXTERNAL NAME [CM.Library.Blocks.SecurityEngine.SQL.Functions].[Triggers].[Trigger1]

deploy assembly. VS SQLCLR debug works fine Smile

|||

to Haplo_69:
which folder should i save the postdeployscript.sql
when and how should i call the postdeploysript.sql?

i have tested your solution:
1. create a postdeployscript.sql at 'test scripts' folder in project directory
2. in project post-build event command, wrote script to call the postdeployscript.sql
but it failed,

|||

postdeploy.sql and predeploy.sql should be in ypur project root. no script is needed in post-build event

|||

I mean: postdeployscript.sql and predeployscript.sql of course Smile

|||This bug has been fixed in SQL 2005 SP1?|||I have SQL 2005 SP1 installed and deploying from Visual Studio is still not possible. I believe the prolem lies in VS not SQL.|||I have two problems; A simple Insert Trigger.

Problem 1:
If I use the example in MSDN and follow all the direction to the letter
but I get this error and I know it exists!

Cannot find the object "[dbo].[Users]" because it does not exist or you
do not have permissions.

If I remove the attribute
[Microsoft.SqlServer.Server.SqlTrigger(Name = "UserUpdate", Target =
"[dbo].[Users]", Event = "FOR INSERT")]

It compiles okay, I have to your postdeployscript.sql to deploy the
Trigger

Problem 2: Kinda show stopper for me

If I employ above work around using postdeployscript.sql every thing
works, my test scripts fire up the trigger and all the right rows are
affected but no break point is hit in C# trigger code. It just passes
through the breakpoint, NO red circle with exclaimation mark in it! No
errors, but this outout;

Auto-attach to process '[2112] [SQL] entropy' on machine 'entropy'
succeeded.
Debugging script from project script file.

(2 row(s) affected)
(0 row(s) returned)
Finished running sp_executesql.
The thread 'entropy\sqlexpress [54]' (0xe5c) has exited with code 0
(0x0).
The thread 'entropy\sqlexpress [54]' (0xe5c) has exited with code 0
(0x0).
The thread 'entropy\sqlexpress [54]' (0xe5c) has exited with code 0
(0x0).
The thread 'entropy\sqlexpress [54]' (0xe5c) has exited with code 0
(0x0).
The program '[2112] [SQL] entropy: entropy\sqlexpress' has exited with
code 0 (0x0).

If I fire up msvsmon.exe and hit the debug button in VS.NET It says;

31/08/2006 8:50:41 AM ENTROPY\p4r1tyB1t connected.

ANY HELP WOULD BE GREATLY APPRICIATED

System State Information:
Login account is part of Administrator account.
VS.NET 2005 Pro on Core Duo Machine 1 GB Ram
Windows XP SP2
I have set proper permission in DCOM configuration
TCP/IP protocol is enabled, firewalls are not running
I am also a member of sysadmin group
SQL Expresss
CLR Debuggin is enabled
Debug generation is set to full
Assembly is marked as unsafe (It does not matter, same problem even
safe)
Project configuration is debug
Permission in msvsmon.exe is also set to my login account, which is
admin account|||If I remember well, you should be member of sysadmin role on the sql2005 db you are trying to debug

CLR test script SELECT returns no row data

Hi,

The test.sql scripts I write to test CLR stored procedures run successfully, but when I want to display the resulting data in the database with a simple "SELECT * from Employee"

I get the result as:
Name Address
- -
No rows affected.
(1 row(s) returned)

But not the actual row is displayed whereas I would expect to see something like:

Name Address
- -
John Doe
No rows affected.
(1 row(s) returned)

I have another database project where doing the same thing displays the row information but there doesn't seem to be a lot different between the two.

Why no results in first case?

Thanks,
Bahadir
You maybe still have the transaction open and uncommitted, thats why you don′t see the actual row.

HTH; Jens SUessmeyer.

http://www.sqlserver2005.de

CLR Stored procedure to access OleDb datasource, how?

I tried to write a CLR stored procedure using C# in SQL 2005 to access an
Access
database.
When I use the OleDbConnection class in System.Data, the procedure throws
SecurityException at runtime.
Output as following:
System.Security.SecurityException: Request for the permission of type
'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.OleDb.OleDbConnection.PermissionDemand()
at System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection
outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at Dbbest.Data.BulkStuff.bulkcopy(String source_oledb_connection_string,
String source_table, String destination_table, Int32 batchSize, Int32
notifyAfter)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.OleDb.OleDbPermission
The Zone of the assembly that failed was:
MyComputerWhen you created the assembly did you set the permission set? If not,
then it is SAFE by default and you will not be able ot get to your
access database. You MAY have to go all the way to UNSAFE to get
there, I have not checked.
CREATE ASSEMBLY SQLCLRTest
FROM 'C:\MyDBApp\SQLCLRTest.dll'
WITH PERMISSION_SET = SAFE
SAFE, EXTERNAL_ACCESS, UNSAFE are the options that you have for this.
Steve

CLR Stored procedure to access Ole datasource, how?

I tried to write a CLR stored procedure using C# in SQL 2005 to access an Access
database.

When I use the OleDbConnection class in System.Data, the procedure throws SecurityException at runtime.
Output as following:

System.Security.SecurityException: Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.OleDb.OleDbConnection.PermissionDemand()
at System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at Dbbest.Data.BulkStuff.bulkcopy(String source_oledb_connection_string, String source_table, String destination_table, Int32 batchSize, Int32 notifyAfter)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.OleDb.OleDbPermission
The Zone of the assembly that failed was:
MyComputer

Hello Va1era,

The exception you encountered indicates that the C# assembly containing the stored procedure that you registered has insufficient permissions to create an OleDbConnection object, with respect to the .Net framework Code Access Security (CAS) policies. This probably means that your assembly was registered WITH PERMISSION_SET = SAFE, which is also the default if PERMISSION_SET is unspecified in the CREATE ASSEMBLY DDL statement.

To fix this, you can re-register your assembly WITH PERMISSION_SET = EXTERNAL_ACCESS to gain access to the ADO.Net classes (including OleDbConnection). If you are using Visual Studio, you will have to make this change from SAFE to EXTERNAL_ACCESS in the properties page of your C# database project.

To understand more about the CAS security permission buckets in SQL Server's hosted CLR (SAFE, EXTERNAL_ACCESS and UNSAFE), you can look at this document: http://bordecal.mvps.org/Nicole/SqlClrCas/SqlClrCasSpeculations.htm. Also, here is the MSDN page on CAS and ADO.Net 2.0: http://msdn2.microsoft.com/en-us/library/0x4t63kb.aspx

Hope this helps.

Thanks,
Ravi

CLR Stored Procedure Not Visible

I am trying to do some time series analysis on data that I have. I've read that the best way to do this is to use CLR to write the manipulation code in .Net and then load the assembly into SQL rather than extracting the data, manipulating it and putting it back again.

I'm using crystal reports with visual studio 2003 to do my reporting. The problem I am facing is that the CLR stored procedures I create using SQLExpress are not visible from my SQL explorer built into Visual Studio 2003. I can create stored procedures using standard transact sql and these are visible, but the CLR stored procedures are not.

I've noticed when I browse the stored procedures in my SQL Management Studio that the image of the stored procedure has a padlock shown in the icon, as if they are locked?

Do I have to explicitly enable a security attribute on CLR stored procedures to make them visible?

Any help would be greatly appreciated.

Try posting this question on the CLR forums: .NET Framework inside SQL Server.

Thanks
Laurentiu

|||

Mic,

Did you find an answer to the padlock icon next to the CLR stored procedures.

I am using sql server 2005, and trying to access them in reporting services.

I must be missing something.

I tried setting permissions to no avail.

Thanks

Tim

CLR Stored Procedure Not Visible

I am trying to do some time series analysis on data that I have. I've read that the best way to do this is to use CLR to write the manipulation code in .Net and then load the assembly into SQL rather than extracting the data, manipulating it and putting it back again.

I'm using crystal reports with visual studio 2003 to do my reporting. The problem I am facing is that the CLR stored procedures I create using SQLExpress are not visible from my SQL explorer built into Visual Studio 2003. I can create stored procedures using standard transact sql and these are visible, but the CLR stored procedures are not.

I've noticed when I browse the stored procedures in my SQL Management Studio that the image of the stored procedure has a padlock shown in the icon, as if they are locked?

Do I have to explicitly enable a security attribute on CLR stored procedures to make them visible?

Any help would be greatly appreciated.

Try posting this question on the CLR forums: .NET Framework inside SQL Server.

Thanks
Laurentiu

|||

Mic,

Did you find an answer to the padlock icon next to the CLR stored procedures.

I am using sql server 2005, and trying to access them in reporting services.

I must be missing something.

I tried setting permissions to no avail.

Thanks

Tim

Thursday, March 8, 2012

CLR procedure to create entries in eventlog

Hi,

I created a SP in C# to write entries to the eventlog.

I works fin but I need to put the security level in External_Access.

Is there a way to do the same with permission level on save by making use of the
System.Diagnostics.EventLogPermission class or is externale_access to only possible way to use it.

Unfortunately you would need external access for this and you wouldnt be able to use SAFE. External Access provides you equal reliablility guarantees as SAFE but however it is a high privilege from security perspective.

Thanks,
-Vineet.

Wednesday, March 7, 2012

Close discussion

We have a sharepoint <\\ces\cesgypdav> that is a WebDAV connection, not an actual fileshare. A SSRS Subscription fails on file write ... "Failure writing file <name here > : The network path was not found" ... to this path.

Can SQL Reporting write to a WebDAV sharepoint?

WebDAV issue is known, need to 'work around'.

This helps: http://sqljunkies.com/WebLog/tpagel/archive/2005/12/23/17682.aspx

Saturday, February 25, 2012

Close connection of SQLExpress!

Hi,

I write a .NET Windows Form that connect to SQLExpress datafile. After updating data, I want to zip the .mdf file and send email. However, I got an exeption that the .mdf file is used by other thread so I cant zip. Even I try to close all connection, I still cant zip.

Is there any way to detach/unlock .mdf file connecting by SQLExpress?

MA.

Hi,

if you are sure you closed down all conenctions, you can use the sp_detach command to detach the database. if you want to close all connection from the server side first you will have to use the ALTER DATABASE command first and change the state of the database to a SINGLe or admin mode.


HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

Hi,

Unfortunaterly, I dont control the connection but I want to force to close all connection from the client side (using C# code).

MA.

|||

Hi MA,

Jens is exactly correct, you'll need to force the database into single user mode:

ALTER DATABASE pubs
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE

This will rollback all transactions and then you can detach the database as you like. I'm not sure what you mean you don't control the connections. If you can not connect to the database, then you can not close it's connections and you will not be able to close the connections.

Mike

Friday, February 24, 2012

Clients?!

Is there any way to write reports for WAP, or other clients'
KKjell,
With RS reports can be generated in HTML. HTML 4.0 is used for uplevel
browsers and HTML3.2 for downlevel browsers. So, for browser-equiped
clients, such smart phones, reports should render just fine. Other formats,
such as cHTML will require writing a custom rendering extension.
Another option is to export the report in XML and apply XSL transformation
using the Data Output tab.
--
Hope this helps.
----
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
----
"Kjell Brandes" <kjell@.brandes.tv> wrote in message
news:uOjow%23lmEHA.3432@.TK2MSFTNGP14.phx.gbl...
> Is there any way to write reports for WAP, or other clients'
> K
>|||Hi Teo, Thanx for your reply!!
About writing rendering extensions.
Is this something you write about in your book, or do you have some tips on
good sites handeling this matter'
reg.
Kjell
"Teo Lachev" <teo.lachev@.nospam.prologika.com> wrote in message
news:e9SW9PsmEHA.3712@.TK2MSFTNGP15.phx.gbl...
> Kjell,
> With RS reports can be generated in HTML. HTML 4.0 is used for uplevel
> browsers and HTML3.2 for downlevel browsers. So, for browser-equiped
> clients, such smart phones, reports should render just fine. Other
formats,
> such as cHTML will require writing a custom rendering extension.
> Another option is to export the report in XML and apply XSL transformation
> using the Data Output tab.
> --
> Hope this helps.
> ----
> Teo Lachev, MCSD, MCT
> Author: "Microsoft Reporting Services in Action"
> Publisher website: http://www.manning.com/lachev
> Buy it from Amazon.com: http://shrinkster.com/eq
> Home page and blog: http://www.prologika.com/
> ----
> "Kjell Brandes" <kjell@.brandes.tv> wrote in message
> news:uOjow%23lmEHA.3432@.TK2MSFTNGP14.phx.gbl...
> > Is there any way to write reports for WAP, or other clients'
> >
> > K
> >
> >
>|||Kjell,
I don't think that the rendering extension interfaces are documented as of
this time. The functionality is there but there is no documentation or
samples to the best of my knowledge. My book doesn't include an example of a
rendering extension.
For more information about this please see the following thread:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=OgC7Pr8eEHA.1604%40TK2MSFTNGP11.phx.gbl&rnum=7&prev=/groups%3Fq%3Drendering%2Bextension%2Bsample%2Bgroup:*.reportingsvcs%26hl%3Den%26lr%3D%26ie%3DUTF-8%26scoring%3Dd%26selm%3DOgC7Pr8eEHA.1604%2540TK2MSFTNGP11.phx.gbl%26rnum%3D7
--
Hope this helps.
----
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
----
"Kjell Brandes" <kjell@.brandes.tv> wrote in message
news:ePnZPxymEHA.2140@.TK2MSFTNGP11.phx.gbl...
> Hi Teo, Thanx for your reply!!
> About writing rendering extensions.
> Is this something you write about in your book, or do you have some tips
on
> good sites handeling this matter'
> reg.
> Kjell
>
> "Teo Lachev" <teo.lachev@.nospam.prologika.com> wrote in message
> news:e9SW9PsmEHA.3712@.TK2MSFTNGP15.phx.gbl...
> > Kjell,
> >
> > With RS reports can be generated in HTML. HTML 4.0 is used for uplevel
> > browsers and HTML3.2 for downlevel browsers. So, for browser-equiped
> > clients, such smart phones, reports should render just fine. Other
> formats,
> > such as cHTML will require writing a custom rendering extension.
> >
> > Another option is to export the report in XML and apply XSL
transformation
> > using the Data Output tab.
> >
> > --
> > Hope this helps.
> >
> > ----
> > Teo Lachev, MCSD, MCT
> > Author: "Microsoft Reporting Services in Action"
> > Publisher website: http://www.manning.com/lachev
> > Buy it from Amazon.com: http://shrinkster.com/eq
> > Home page and blog: http://www.prologika.com/
> > ----
> >
> > "Kjell Brandes" <kjell@.brandes.tv> wrote in message
> > news:uOjow%23lmEHA.3432@.TK2MSFTNGP14.phx.gbl...
> > > Is there any way to write reports for WAP, or other clients'
> > >
> > > K
> > >
> > >
> >
> >
>

clients sometimes get locked and can't write

I have an SQL 2000 back end. We have a couple of databases with about 12-20
tables a piece. About once or twice a month there are times for up to an
hour or so where no one can write from any of the front end applications to
the SQL 2000 back end. Each application gives their own error which all are
basically a time out waiting to write. Often times the system will just
start working again on its own.
When this happens the first thing we check in the Enterprise Manager is for
any locks and there are none. We then check to see if one of the other
applications like Access 2003, Labview or others can write to the database
and we see they cannot. Next we see if we can open the table on the SQL
server and edit or append and we CAN from the Enterprise Manager?
Thinking that there might be someone locking a record or a page we kick
everyone out and just let one person (sometimes myself as an admin) try to
work and they cannot. We then restart the SQL server and the workstations
and have someone try again and they still fail.
The only thing that I have seen help get it out of this state is when I go
to my daily maintenance jobs and run both my integrity check and my
optimization plan. The Integrety Check plan was done with the wizard and
it:
1. Checks the integrity of all user database
2. Includes indexes
3. Attempts to repair minor problems.
4. Run every day at 12:00 AM
The Optimization plan is set to:
1. Reorganize Data and Index Pages
2. Change free space to 10%
3. Run every day at 1:30 AM
Finally, when I look in the Event Viewer logs for anything strange I really
do not see anything in the app, security, or system logs anywhere near the
time of the start of the errors.
Sounds like the SQL Server Agents for the SQL Server instances aren't
running sometimes. Goto start->administrative tools->services and
look for the SQL Server Agent (your server instance name) entries and
see their status. Should be in "Started" state. If not started,
click on the entry and click start in top left corner of pane.
SQL Server Agents are the programs that act as proxies to enable
remote access to a SQL server instance. If they are not running,
nobody will be able to gain access to the server, and will receive
time out errors instead.
Some programs, such as backups, may stop the agents so they can take a
snapshot of the database. These programs should start the agents as
soon as they are done. If you find the agents in a stopped state in
the next outage, you should try to trace down what program was
executing at the time they were stopped, and check if that program is
configured properly.
|||I don't think it is the agent because the users are able to read the data
remotely. Also, the only maintenance that is done is done at 1-3 AM. This
problem happens randomly mid day.
"Andy" <anedza@.infotek-consulting.com> wrote in message
news:e1159a72-4a2a-449d-a8d7-d22be76d6595@.q78g2000hsh.googlegroups.com...
> Sounds like the SQL Server Agents for the SQL Server instances aren't
> running sometimes. Goto start->administrative tools->services and
> look for the SQL Server Agent (your server instance name) entries and
> see their status. Should be in "Started" state. If not started,
> click on the entry and click start in top left corner of pane.
> SQL Server Agents are the programs that act as proxies to enable
> remote access to a SQL server instance. If they are not running,
> nobody will be able to gain access to the server, and will receive
> time out errors instead.
> Some programs, such as backups, may stop the agents so they can take a
> snapshot of the database. These programs should start the agents as
> soon as they are done. If you find the agents in a stopped state in
> the next outage, you should try to trace down what program was
> executing at the time they were stopped, and check if that program is
> configured properly.
>
>
>

clients sometimes get locked and can't write

I have an SQL 2000 back end. We have a couple of databases with about 12-20
tables a piece. About once or twice a month there are times for up to an
hour or so where no one can write from any of the front end applications to
the SQL 2000 back end. Each application gives their own error which all are
basically a time out waiting to write. Often times the system will just
start working again on its own.
When this happens the first thing we check in the Enterprise Manager is for
any locks and there are none. We then check to see if one of the other
applications like Access 2003, Labview or others can write to the database
and we see they cannot. Next we see if we can open the table on the SQL
server and edit or append and we CAN from the Enterprise Manager'
Thinking that there might be someone locking a record or a page we kick
everyone out and just let one person (sometimes myself as an admin) try to
work and they cannot. We then restart the SQL server and the workstations
and have someone try again and they still fail.
The only thing that I have seen help get it out of this state is when I go
to my daily maintenance jobs and run both my integrity check and my
optimization plan. The Integrety Check plan was done with the wizard and
it:
1. Checks the integrity of all user database
2. Includes indexes
3. Attempts to repair minor problems.
4. Run every day at 12:00 AM
The Optimization plan is set to:
1. Reorganize Data and Index Pages
2. Change free space to 10%
3. Run every day at 1:30 AM
Finally, when I look in the Event Viewer logs for anything strange I really
do not see anything in the app, security, or system logs anywhere near the
time of the start of the errors.Sounds like the SQL Server Agents for the SQL Server instances aren't
running sometimes. Goto start->administrative tools->services and
look for the SQL Server Agent (your server instance name) entries and
see their status. Should be in "Started" state. If not started,
click on the entry and click start in top left corner of pane.
SQL Server Agents are the programs that act as proxies to enable
remote access to a SQL server instance. If they are not running,
nobody will be able to gain access to the server, and will receive
time out errors instead.
Some programs, such as backups, may stop the agents so they can take a
snapshot of the database. These programs should start the agents as
soon as they are done. If you find the agents in a stopped state in
the next outage, you should try to trace down what program was
executing at the time they were stopped, and check if that program is
configured properly.|||I don't think it is the agent because the users are able to read the data
remotely. Also, the only maintenance that is done is done at 1-3 AM. This
problem happens randomly mid day.
"Andy" <anedza@.infotek-consulting.com> wrote in message
news:e1159a72-4a2a-449d-a8d7-d22be76d6595@.q78g2000hsh.googlegroups.com...
> Sounds like the SQL Server Agents for the SQL Server instances aren't
> running sometimes. Goto start->administrative tools->services and
> look for the SQL Server Agent (your server instance name) entries and
> see their status. Should be in "Started" state. If not started,
> click on the entry and click start in top left corner of pane.
> SQL Server Agents are the programs that act as proxies to enable
> remote access to a SQL server instance. If they are not running,
> nobody will be able to gain access to the server, and will receive
> time out errors instead.
> Some programs, such as backups, may stop the agents so they can take a
> snapshot of the database. These programs should start the agents as
> soon as they are done. If you find the agents in a stopped state in
> the next outage, you should try to trace down what program was
> executing at the time they were stopped, and check if that program is
> configured properly.
>
>
>

Sunday, February 12, 2012

Client Application and SQL Mirroring

I have an application where the SQL Database is configured within (I give it
the server name, database name and SQL access info). I did not write the app
and was wondering if it could be used with SQL mirroring high availability
without having to reconfigure the client app.
I skimmed over the link 'SQL Server 2005 Books Online Overview of Database
Mirroring' http://msdn2.microsoft.com/en-us/library/ms189852.aspx and still
am not clear about how the client application sees the mirrored database on a
failure when using the top level mirroring feature - High Availability.
Thanks
New2SQLHi
From www.connectionstrings.com
/*
If you connect with ADO.NET or the SQL Native Client to a database that is
being mirrored, your application can take advantage of the drivers ability
to automatically redirect connections when a database mirroring failover
occurs. You must specify the initial principal server and database in the
connection string and the failover partner server.
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial
Catalog=myDataBase;Integrated Security=True;
*/
"New2SQL" <New2SQL@.discussions.microsoft.com> wrote in message
news:189496E6-29DC-484B-961F-F8E895363558@.microsoft.com...
>I have an application where the SQL Database is configured within (I give
>it
> the server name, database name and SQL access info). I did not write the
> app
> and was wondering if it could be used with SQL mirroring high availability
> without having to reconfigure the client app.
> I skimmed over the link 'SQL Server 2005 Books Online Overview of Database
> Mirroring' http://msdn2.microsoft.com/en-us/library/ms189852.aspx and
> still
> am not clear about how the client application sees the mirrored database
> on a
> failure when using the top level mirroring feature - High Availability.
> Thanks
> New2SQL
>