Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Sunday, March 25, 2012

Cluster installation & Domain Group requirements...

Why does a cluster install of SQL2005 require access to a domain group and what is the purpose of having to create a domain group for the cluster installation? Other than the blurb mentioned in BOL I'm having a hard time finding any information out about this requirement.

From BOL: How to create a failover cluster.

Section 18: On the Domain Groups for Clustered Services page, provide a DomainName\GroupName for each clustered service being installed: the SQL Server service, SQL Server Agent service, Analysis Services service, and Full-Text Search service must run as domain accounts that are members of the built-in administrators group on each node of the cluster. To proceed, click Next. For more information, see Domain Groups for Clustered Services.

The purpose for domain groups in cluster installation is security consideration. As SQL Server service accounts in a local group can be changed or removed after SQL Server 2005 is installed. Then the security setting like ACL will be lost. That is why domain group\account is introduced.

|||

Ok, that's kind of what I thought it was for.

Is there any way to change the group after installation? Can I just move the account to another group and be done with it? Or is there somewhere (in SQL Server) that I need to update the group if we desire to change groups?

sqlsql

Tuesday, March 20, 2012

Cluster 2005 need help please

quick overview

2 nodes-cluster setup from node 1

I setup a cluster, created 4 groups

1.cluster 2.msdtc 3.sqlinstance1 4.sqlinstance2

I want to create an active\passive on both nodes. (onenode will be the active node for on sql install while the other is passive.

I want to repeat this fo rthe second node, the second node being active and node 1 passive.

I logged into node 1 and I installed sql 2005 in failover cluster into sqlinstance 1., everyhting was fine, failover etc.

Now I logged into node 2 and ran sql 2005 setup to create a failover cluster.

I chose to install into sql instance 2.

Database unable to install with error "failed to set registry settings for server network libraries. acition is setdefaults.error 11001, no such host is known.

If I am not setting this up correclty please let me know

thanks

everything was fine. I logged onto node 2, was going to

Which node owns the disk resources that you are trying to install to? You can very simply run the setup routine twice from the same node. Then when you are done with both installs, all you have to do is move the group for one of the instances to the other node and you are done with your configuration. The node that you install from is irrelevant to where you want the instances to run.|||

Hi,

I don't know specifically the answer to your question, but here is a white paper that you might find useful:

SQL Server 2005 Failover Clustering
http://www.microsoft.com/downloads/details.aspx?FamilyID=818234dc-a17b-4f09-b282-c6830fead499&DisplayLang=en

|||

the architect wants sql installed on both nodes. All groups and reasources are owned by node 2, just not the first install of sql which is still owned by node 1.

thanks

|||

Hi,

This issue happens due to a orphan registry key.

Delete the followinh key from both nodes:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.X\Cluster

Be carefull while deleting the key, as quorum checkpointnig could cause issues.

HTH

Cluster 2005 need help please

quick overview

2 nodes-cluster setup from node 1

I setup a cluster, created 4 groups

1.cluster 2.msdtc 3.sqlinstance1 4.sqlinstance2

I want to create an active\passive on both nodes. (onenode will be the active node for on sql install while the other is passive.

I want to repeat this fo rthe second node, the second node being active and node 1 passive.

I logged into node 1 and I installed sql 2005 in failover cluster into sqlinstance 1., everyhting was fine, failover etc.

Now I logged into node 2 and ran sql 2005 setup to create a failover cluster.

I chose to install into sql instance 2.

Database unable to install with error "failed to set registry settings for server network libraries. acition is setdefaults.error 11001, no such host is known.

If I am not setting this up correclty please let me know

thanks

everything was fine. I logged onto node 2, was going to

Which node owns the disk resources that you are trying to install to? You can very simply run the setup routine twice from the same node. Then when you are done with both installs, all you have to do is move the group for one of the instances to the other node and you are done with your configuration. The node that you install from is irrelevant to where you want the instances to run.|||

Hi,

I don't know specifically the answer to your question, but here is a white paper that you might find useful:

SQL Server 2005 Failover Clustering
http://www.microsoft.com/downloads/details.aspx?FamilyID=818234dc-a17b-4f09-b282-c6830fead499&DisplayLang=en

|||

the architect wants sql installed on both nodes. All groups and reasources are owned by node 2, just not the first install of sql which is still owned by node 1.

thanks

|||

Hi,

This issue happens due to a orphan registry key.

Delete the followinh key from both nodes:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.X\Cluster

Be carefull while deleting the key, as quorum checkpointnig could cause issues.

HTH

Monday, March 19, 2012

cluster ? on muliple data disks

Hi,
I have setup a 2 node a/p cluster. During install i picked the s drive as
the data drive, and the L drive as the log drive.
i was able to create a db on the S drive
now i want to create a database and use the z drive. but it won't show me
the Z drive as a option when i try to browse to a different drive as part of
the create new db steps.
both disks are disk resources managed by the cluster
in the past, i have been able to do it on a non clustered server
what is the trick with a cluster?
The "trick" is twofold. First, you have to make the disks Cluster Resources
and put them in the resource group for the SQL virtual server. I am
guessing this is where you are at. Second, you have to make the SQL Service
dependent on the disk resource. You will have to take the service offline
to make the change. Look at the dependency relationship between the SQL
service and the existing disk resources.
Geoff N. Hiten
Microsoft SQL Server MVP
"jason" <jason@.discussions.microsoft.com> wrote in message
news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
> Hi,
> I have setup a 2 node a/p cluster. During install i picked the s drive as
> the data drive, and the L drive as the log drive.
> i was able to create a db on the S drive
> now i want to create a database and use the z drive. but it won't show me
> the Z drive as a option when i try to browse to a different drive as part
> of
> the create new db steps.
> both disks are disk resources managed by the cluster
> in the past, i have been able to do it on a non clustered server
> what is the trick with a cluster?
|||Geoff, that did it thanks!
"Geoff N. Hiten" wrote:

> The "trick" is twofold. First, you have to make the disks Cluster Resources
> and put them in the resource group for the SQL virtual server. I am
> guessing this is where you are at. Second, you have to make the SQL Service
> dependent on the disk resource. You will have to take the service offline
> to make the change. Look at the dependency relationship between the SQL
> service and the existing disk resources.
> Geoff N. Hiten
> Microsoft SQL Server MVP
> "jason" <jason@.discussions.microsoft.com> wrote in message
> news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
>
>

cluster ? on muliple data disks

Hi,
I have setup a 2 node a/p cluster. During install i picked the s drive as
the data drive, and the L drive as the log drive.
i was able to create a db on the S drive
now i want to create a database and use the z drive. but it won't show me
the Z drive as a option when i try to browse to a different drive as part of
the create new db steps.
both disks are disk resources managed by the cluster
in the past, i have been able to do it on a non clustered server
what is the trick with a cluster?The "trick" is twofold. First, you have to make the disks Cluster Resources
and put them in the resource group for the SQL virtual server. I am
guessing this is where you are at. Second, you have to make the SQL Service
dependent on the disk resource. You will have to take the service offline
to make the change. Look at the dependency relationship between the SQL
service and the existing disk resources.
Geoff N. Hiten
Microsoft SQL Server MVP
"jason" <jason@.discussions.microsoft.com> wrote in message
news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
> Hi,
> I have setup a 2 node a/p cluster. During install i picked the s drive as
> the data drive, and the L drive as the log drive.
> i was able to create a db on the S drive
> now i want to create a database and use the z drive. but it won't show me
> the Z drive as a option when i try to browse to a different drive as part
> of
> the create new db steps.
> both disks are disk resources managed by the cluster
> in the past, i have been able to do it on a non clustered server
> what is the trick with a cluster?|||Geoff, that did it thanks!
"Geoff N. Hiten" wrote:
> The "trick" is twofold. First, you have to make the disks Cluster Resources
> and put them in the resource group for the SQL virtual server. I am
> guessing this is where you are at. Second, you have to make the SQL Service
> dependent on the disk resource. You will have to take the service offline
> to make the change. Look at the dependency relationship between the SQL
> service and the existing disk resources.
> Geoff N. Hiten
> Microsoft SQL Server MVP
> "jason" <jason@.discussions.microsoft.com> wrote in message
> news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
> > Hi,
> > I have setup a 2 node a/p cluster. During install i picked the s drive as
> > the data drive, and the L drive as the log drive.
> > i was able to create a db on the S drive
> > now i want to create a database and use the z drive. but it won't show me
> > the Z drive as a option when i try to browse to a different drive as part
> > of
> > the create new db steps.
> >
> > both disks are disk resources managed by the cluster
> >
> > in the past, i have been able to do it on a non clustered server
> >
> > what is the trick with a cluster?
>
>

cluster ? on muliple data disks

Hi,
I have setup a 2 node a/p cluster. During install i picked the s drive as
the data drive, and the L drive as the log drive.
i was able to create a db on the S drive
now i want to create a database and use the z drive. but it won't show me
the Z drive as a option when i try to browse to a different drive as part of
the create new db steps.
both disks are disk resources managed by the cluster
in the past, i have been able to do it on a non clustered server
what is the trick with a cluster?The "trick" is twofold. First, you have to make the disks Cluster Resources
and put them in the resource group for the SQL virtual server. I am
guessing this is where you are at. Second, you have to make the SQL Service
dependent on the disk resource. You will have to take the service offline
to make the change. Look at the dependency relationship between the SQL
service and the existing disk resources.
Geoff N. Hiten
Microsoft SQL Server MVP
"jason" <jason@.discussions.microsoft.com> wrote in message
news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
> Hi,
> I have setup a 2 node a/p cluster. During install i picked the s drive as
> the data drive, and the L drive as the log drive.
> i was able to create a db on the S drive
> now i want to create a database and use the z drive. but it won't show me
> the Z drive as a option when i try to browse to a different drive as part
> of
> the create new db steps.
> both disks are disk resources managed by the cluster
> in the past, i have been able to do it on a non clustered server
> what is the trick with a cluster?|||Geoff, that did it thanks!
"Geoff N. Hiten" wrote:

> The "trick" is twofold. First, you have to make the disks Cluster Resourc
es
> and put them in the resource group for the SQL virtual server. I am
> guessing this is where you are at. Second, you have to make the SQL Servi
ce
> dependent on the disk resource. You will have to take the service offline
> to make the change. Look at the dependency relationship between the SQL
> service and the existing disk resources.
> Geoff N. Hiten
> Microsoft SQL Server MVP
> "jason" <jason@.discussions.microsoft.com> wrote in message
> news:FA7F35A5-7EDE-4162-90CE-E6AAD7D43057@.microsoft.com...
>
>

Clueless client who wants to create a table using reserved words

Hello all,
I have a database that supports two different applications.
For arguments sake I'll call them "intelligent app" and "clueless app"

The client that provided me the schema for the clueless app used reserved words as field names.
The words used are:
value, state, and time

I explained to the client that modifying them could prevent current/future issues.

The client is an "oracle" db (and in my mind should know better but ....) and responded back to me with the following:

BEGIN QUOTE
They are not currently reserved and there is no guarantee they will ever be reserved. In fact, the SQL server line eliminates as many words from the reserved list as they add with new releases. There are other words on the
possible future reserved keyword list that I do not wish to avoid either unless forced to some day, like depth, size, class, zone, level and others.
END QUOTE

Now for the assistance request, where can I find the documented ramifications of using reserved words?
I want to have my documentation (and my ducks lined up) when this clients portion of the app fails.

Any and all assistance is greatly appreciated.

T. Mullins'splain dat one again... Whyfor you have to be prepared when their Data Modeler's choices hit the fan?

SQL Server will gleefully tolerate them, as long as they are properly quoted using [], so what the heck do you care? The developers may revolt when their tools act up, but those column names aren't your choices, so they aren't your problems as far as I can see.

-PatP|||Do a search for "Reserved Keywords" in Books OnLine, and you should be presented with the current list of reserved words. One caution, I did come up with tw lists, one for C++ and one for T-SQL.

A quote from this article reads:
Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, this can be done only using delimited identifiers.

This is pretty much what Pat has said in his post, though.|||Gracias guys !
I knew of the BOL & MSDN info. I was hoping to have examples of apps that have crashed and burned due to poor design. :)
I think I'll wait in the tall grass ......
Regards to all.
tam

Originally posted by MCrowley
Do a search for "Reserved Keywords" in Books OnLine, and you should be presented with the current list of reserved words. One caution, I did come up with tw lists, one for C++ and one for T-SQL.

A quote from this article reads:
Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, this can be done only using delimited identifiers.

This is pretty much what Pat has said in his post, though.|||Oh, there are fabulous stories that go from the 1970s into the 1990s, but they peter out pretty quickly there. By that point in time, nearly everybody in the compiler/database/toolset community had abandoned the L-R grammer parsers for yacc or its equivalent, which allowed them to quickly and easily make it possible to make a product's entire grammer "quote sensistive". That change allowed the product vendors to make it possible for the user to "un-reserve" words that were otherwise reserved by quoting them somehow.

That change, combined with wider use of code-generators (sometimes by different names, but code generators nonetheless) made it relatively easy to "dodge the bullet" of reserved words.

It can still be a pain in the posterior, but it is no longer a case of Mohammed and the Mountian. Now the developer can work around the reserved-word problem if they choose to do so.

-PatP

CLR UDTs bigger than 8000 bytes

Hi there,
Say I wanted to create a "compound" type, purely to pass as a parameter
to a stored procedure, but one of the components was NTEXT or
NVARCHAR(MAX). Say it was something like:
- Author NVARCHAR(256)
- IP address VARCHAR(16)
- Comment NVARCHAR(MAX)
How would I go about doing this? My code works fine if the UDT package
is less than 8000 bytes, but fails if it's greater than that (which is
understandable since I had to put MaxByteSize = 8000 into the UDT
definition). If the package is too big, I get an
IndexOutOfRangeException in
System.Data.SqlClient.TdsParser.TdsExecuteRPC().
Is the 8000-byte limit a "hard" limit that I can't work around? As I
mentioned, this is purely to pass as a parameter to a stored procedure,
it'll never be used as a column in a table.
Or am I misunderstanding something and I don't even need to make this a
real UDT since it won't ever be stored as a column? Is there a way for
me to pass a regular .NET object to a CLR stored procedure?
(This example is very simplistic, I know - I could just pass three
individual parameters instead of one compound one in this case. The
actual situation is more complicated though.)
Many thanks,
GeoffGeoff (opinionatedg@.gmail.com) writes:
> Say I wanted to create a "compound" type, purely to pass as a parameter
> to a stored procedure, but one of the components was NTEXT or
> NVARCHAR(MAX). Say it was something like:
> - Author NVARCHAR(256)
> - IP address VARCHAR(16)
> - Comment NVARCHAR(MAX)
> How would I go about doing this? My code works fine if the UDT package
> is less than 8000 bytes, but fails if it's greater than that (which is
> understandable since I had to put MaxByteSize = 8000 into the UDT
> definition). If the package is too big, I get an
> IndexOutOfRangeException in
> System.Data.SqlClient.TdsParser.TdsExecuteRPC().
> Is the 8000-byte limit a "hard" limit that I can't work around?
That's right.

> Or am I misunderstanding something and I don't even need to make this a
> real UDT since it won't ever be stored as a column? Is there a way for
> me to pass a regular .NET object to a CLR stored procedure?
Check out the current thread "DataRow in a CLR Stored Procedure". There
are some suggestions on binary serialization.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hi,
thanks for that - at least I know I'm not missing something simple at
the UDT/parameter level.
I've checked out the thread "DataRow in a CLR Stored Procedure" as you
suggested - interesting stuff. It would just mean serializing the
values manually before the call, rather than the serialization
happening as part of the call... The objects themselves wouldn't then
need to be UDTs, so there'd be no limit. Cool.
Many thanks,
Geoff

CLR TVF -> Using Datareader...

Hi
I'm trying to create a CLR-TVF which should do some stuff (in my sample it's
just getting the syscolumns name column for the database _ODS).
I’ve got this error:
An error occurred while getting new row from user defined Table Valued
Function :
System.InvalidOperationException: Data access is not allowed in this
context. Either the context is a function or method not marked with
DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain
data from FillRow method of a Table Valued Function, or is a UDT validation
method.
Question: Is it really not possible to make a sql-query within the C#-Part
of the CLR? I know, I could easily do it using a StoredProc…but I need a T
VF.
Thanks for your help…
Here is the code:
[Microsoft.SqlServer.Server.SqlFunction
(FillRowMethodName = "FillRow2",
DataAccess = DataAccessKind.Read,
TableDefinition = "fld_colname NVARCHAR(4000)" )]
public static IEnumerable LoadSysColumns(string str2)
{
return str2;
}
public static void FillRow2(object row,
out string str2)
{
// creating a connection using the current sqlserver-context
using (SqlConnection connection = new SqlConnection("context
connection=true"))
{
connection.Open();
SqlCommand sqlCommand = connection.CreateCommand();
sqlCommand.CommandText = "select NAME from _ODS.dbo.SYSCOLUMNS";
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
sqlDataReader.Read();
str2 = sqlDataReader.GetValue(0).ToString();
}
}"Dominic" <Dominic@.discussions.microsoft.com> wrote in message
news:7638A0AE-0976-4DAC-8512-93FB84C048A4@.microsoft.com...
> Hi
> I'm trying to create a CLR-TVF which should do some stuff (in my sample
> it's
> just getting the syscolumns name column for the database _ODS).
> I've got this error:
> An error occurred while getting new row from user defined Table Valued
> Function :
> System.InvalidOperationException: Data access is not allowed in this
> context. Either the context is a function or method not marked with
> DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain
> data from FillRow method of a Table Valued Function, or is a UDT
> validation
> method.
> Question: Is it really not possible to make a sql-query within the C#-Part
> of the CLR? I know, I could easily do it using a StoredProc.but I need a
> TVF.
> Thanks for your help.
> Here is the code:
> [Microsoft.SqlServer.Server.SqlFunction
> (FillRowMethodName = "FillRow2",
> DataAccess = DataAccessKind.Read,
> TableDefinition = "fld_colname NVARCHAR(4000)" )]
> public static IEnumerable LoadSysColumns(string str2)
> {
> return str2;
> }
> public static void FillRow2(object row,
> out string str2)
> {
> // creating a connection using the current sqlserver-context
> using (SqlConnection connection = new SqlConnection("context
> connection=true"))
> {
> connection.Open();
> SqlCommand sqlCommand = connection.CreateCommand();
> sqlCommand.CommandText = "select NAME from
> _ODS.dbo.SYSCOLUMNS";
> SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
> sqlDataReader.Read();
> str2 = sqlDataReader.GetValue(0).ToString();
> }
> }
>
Any data access should be in the LoadSysColumns method, not in the
FillRowMethod. In LoadSysColumns just fill a List<string> and return that.
SQL will enumerate it and pass each member to your FillRowMethod, EG:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Collections.Generic;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction
(FillRowMethodName = "FillRow2",
DataAccess = DataAccessKind.None,
SystemDataAccess = SystemDataAccessKind.Read,
TableDefinition = "fld_colname NVARCHAR(4000)")]
public static IEnumerable LoadSysColumns()
{
List<string> names = new List<string>();
using (SqlConnection connection = new SqlConnection("context
connection=true"))
{
connection.Open();
SqlCommand sqlCommand = connection.CreateCommand();
sqlCommand.CommandText = "select NAME from dbo.SYSCOLUMNS";
using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
while (sqlDataReader.Read())
{
names.Add(sqlDataReader.GetValue(0).ToString());
}
}
return names;
}
public static void FillRow2(object row, out string str2)
{
str2 = (string)row;
}
};
David|||Thanks David...works fine!
"David Browne" wrote:

> "Dominic" <Dominic@.discussions.microsoft.com> wrote in message
> news:7638A0AE-0976-4DAC-8512-93FB84C048A4@.microsoft.com...
> Any data access should be in the LoadSysColumns method, not in the
> FillRowMethod. In LoadSysColumns just fill a List<string> and return that
.
> SQL will enumerate it and pass each member to your FillRowMethod, EG:
>
> using System;
> using System.Data;
> using System.Data.SqlClient;
> using System.Data.SqlTypes;
> using Microsoft.SqlServer.Server;
> using System.Collections;
> using System.Collections.Generic;
> public partial class UserDefinedFunctions
> {
> [Microsoft.SqlServer.Server.SqlFunction
> (FillRowMethodName = "FillRow2",
> DataAccess = DataAccessKind.None,
> SystemDataAccess = SystemDataAccessKind.Read,
> TableDefinition = "fld_colname NVARCHAR(4000)")]
> public static IEnumerable LoadSysColumns()
> {
> List<string> names = new List<string>();
> using (SqlConnection connection = new SqlConnection("context
> connection=true"))
> {
> connection.Open();
> SqlCommand sqlCommand = connection.CreateCommand();
> sqlCommand.CommandText = "select NAME from dbo.SYSCOLUMNS";
> using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
> while (sqlDataReader.Read())
> {
> names.Add(sqlDataReader.GetValue(0).ToString());
> }
> }
> return names;
> }
> public static void FillRow2(object row, out string str2)
> {
> str2 = (string)row;
> }
> };
>
> David
>
>

Sunday, March 11, 2012

CLR Trigger Error: Could not find Type xxxx in Assembly

I've got the following code (C# code) but when I execute the Create Trigger
statement I get the error
"Could not find Type 'InheritanceTriggers' in assembly 'CLRTriggers'
I believe I'm satisfying all the rules: the class is public, the method is
public, and the method is static.
Anythoughts?
Create Trigger EnforceInheritanceTrigger on [Person]
For INSERT as External Name CLRTriggers.InheritanceTriggers.EnforceBaseObjec
t
GO
CLRTriggers.dll code below
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
namespace My.SQLServer
{
public class InheritanceTriggers
{
[SqlTrigger(Name = @."EnforceInheritanceTrigger", Target =
"[dbo].[Person]", Event = "FOR INSERT")]
public static void EnforceBaseObject()
{
SqlTriggerContext context = SqlContext.TriggerContext;
String SQLForInserted = "SELECT * FROM INSERTED;";
string ATableName = "dbo.Person";
if (context.TriggerAction == TriggerAction.Insert)
{
using (SqlConnection connection
= new SqlConnection(@."context connection=true"))
{
connection.Open();
SqlCommand command = new SqlCommand(SQLForInserted,
connection);
SqlDataReader reader = command.ExecuteReader();
while(reader.Read())
{
System.Guid id = (System.Guid)reader[0];
string s = <sql statement is here>;
SqlCommand command1 = new SqlCommand(s, connection);
SqlPipe pipe = SqlContext.Pipe;
pipe.Send(s);
}
reader.Close();
}
}
}
}
}
> Create Trigger EnforceInheritanceTrigger on [Person]
> For INSERT as External Name
> CLRTriggers.InheritanceTriggers.EnforceBaseObject
You need to include your namespace:
Create Trigger EnforceInheritanceTrigger on [Person]
For INSERT as External Name
CLRTriggers.[My.SQLServer.InheritanceTriggers].EnforceBaseObject
Steven|||Unfortunately, that still didn't help:
Could not find Type 'My.SQLServer.InheritanceTriggers' in assembly
'CLRTriggers'.
but thanks for the suggestion...at least it gave me something new to try. :
)
"Steven Hemingray [MSFT]" wrote:

>
> You need to include your namespace:
> Create Trigger EnforceInheritanceTrigger on [Person]
> For INSERT as External Name
> CLRTriggers.[My.SQLServer.InheritanceTriggers].EnforceBaseObject
> Steven
>
>|||I beg your pardon! I got my namespaces mixed up and you are absolutely
correct! Thank you Steve H! (I'll bet you were saying to yourself, "this
guy's nuts", I know that's the problem) :)
"Steven Hemingray [MSFT]" wrote:

>
> You need to include your namespace:
> Create Trigger EnforceInheritanceTrigger on [Person]
> For INSERT as External Name
> CLRTriggers.[My.SQLServer.InheritanceTriggers].EnforceBaseObject
> Steven
>
>

CLR Table valued functions error

Hi,

I'm trying to create a CLR functions

this is the Sql Function attribute and the FillRowMethod signature

[Microsoft.SqlServer.Server.SqlFunction(DataAccess = DataAccessKind.Read, SystemDataAccess = SystemDataAccessKind.Read,

FillRowMethodName = "FillRows",IsPrecise=true,

TableDefinition = "SOCIETA nvarchar(55),CLIENTE nvarchar(150),NUMEROCONTRATTO nvarchar(255),FIRMA datetime,CHIUSURA datetime,AUTORIZZATO float"

)]

publicstaticIEnumerable dbf_Create_RiepilogoAccordi(SqlInt32 commessa, SqlInt32 tipo_commessa, SqlInt32 progetto, SqlInt32 DAC, SqlInt32 figura, SqlDateTime dataFatturazioneDa, SqlDateTime dataFatturazioneA)

publicstaticvoid FillRows(Object obj, outSqlString SOCIETA, outSqlString CLIENTE, outSqlString NUMEROCONTRATTO, outSqlDateTime FIRMA, outSqlDateTime CHIUSURA, SqlDouble AUTORIZZATO)

Whe I try to deploy my function, I get the following error:

Error 1 Function signature of "FillRow" method (as designated by SqlFunctionAttribute.FillRowMethodName) does not match SQL declaration for table valued CLR function 'dbf_Create_RiepilogoAccordi' due to column 6. CM.Reports.SIA.RiepilogoAccordi

I get this error whichever combination of name/value I use for column 6

Can someone help me?

Thanks

Marco


I forgot to mark parameter AUTORIZZATO as an out parameter. the signature should be

publicstaticvoid FillRows(Object obj, outSqlString SOCIETA, outSqlString CLIENTE, outSqlString NUMEROCONTRATTO, outSqlDateTime FIRMA, outSqlDateTime CHIUSURA, out SqlDouble AUTORIZZATO)

CLR Stored procedure

Can I create a CLR stored procedure in VB or C# to print a file. Please give the code sample

All you would need to do it create a SQL Server project, add a stored procedure class, write your printing code inside there, and then deploy it to the database.

You probably shouldn't be doing this though. Any CLR stored procedures or functions should abide by the same principles as the database, which is to not rely on any resources which may not be there. Communicating with a printer is prone to this type of problem as the network may be down, or the printer may be off or out of paper etc. Therefore it shouldn't really be a stored procedure.

CLR procedures for SQL Express with VB Express

Hello,

Does anyone know if is it possible to create CLR procedures for SQL Express with VB Express?

Regards,

hi,

AFAIK, yes, it is, you only have to deploy them "by hand"..

regards

|||

Hi,

Do you have details how to do that? I'm new to SQL 2005 and I can only find information about creating CLR procedures pointing to Visual Studio Database Project, which is not available on the Express version.

Thanks

|||

hi,

Gustavo Bilinski wrote:

Do you have details how to do that? I'm new to SQL 2005 and I can only find information about creating CLR procedures pointing to Visual Studio Database Project, which is not available on the Express version.

Thanks

yes, only VS professional or higher provides the SQL CLR template you can start from, but even Express editions should be able to write them... of course you should implement the skeleton your self as, again, only Professional or higher editions provide it.. you have to imports specific Namespaces, and declare specific attributes for class members and methods.. but when you're finished, the reuslt is actually the same..

regards

CLR procedures for SQL Express with VB Express

Hello,

Does anyone know if is it possible to create CLR procedures for SQL Express with VB Express?

Regards,

hi,

AFAIK, yes, it is, you only have to deploy them "by hand"..

regards

|||

Hi,

Do you have details how to do that? I'm new to SQL 2005 and I can only find information about creating CLR procedures pointing to Visual Studio Database Project, which is not available on the Express version.

Thanks

|||

hi,

Gustavo Bilinski wrote:

Do you have details how to do that? I'm new to SQL 2005 and I can only find information about creating CLR procedures pointing to Visual Studio Database Project, which is not available on the Express version.

Thanks

yes, only VS professional or higher provides the SQL CLR template you can start from, but even Express editions should be able to write them... of course you should implement the skeleton your self as, again, only Professional or higher editions provide it.. you have to imports specific Namespaces, and declare specific attributes for class members and methods.. but when you're finished, the reuslt is actually the same..

regards

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.

CLR procedure calling webservice

Hi, I want to create following procedure to call a webservice. build ok
execution not ok.
When i do it in a seperated program it works. in the clr procedure not.
It always end with 'System.InvalidOperationException' occurred in
System.Xml.dll
Can some one help me.
Ludo
SQL code:
exec dbo.SendStatusToWebservice 'SQL2K5','TEST Ludo','GREEN'
.Net code
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Diagnostics;
public partial class CLR_Procedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
}
public static void SendStatusToWebservice(SqlString MyAppl, SqlString
MyMessage, SqlString MyStatus)
{
string log;
// Connect to webservice and add logging to it
SQL_UDP.bgc.wss.Library wlib = new SQL_UDP.bgc.wss.Library();
wlib.Credentials = System.Net.CredentialCache.DefaultCredentials;
log = wlib.WSScreateLog(MyAppl.Value);
wlib.WSSwriteLog(log, MyMessage.Value);// + " at @. " +
DateTime.Now.ToString);
wlib.SetBatchStatus(MyStatus.Value, log);
}
};
Debug result:
Auto-attach to process '[3068] [SQL] bgc-mikmxeue486' on machine
'bgc-mikmxeue486' succeeded.
Debugging script from project script file.
The thread 'bgc-mikmxeue486 [61]' (0xd60) has exited with code 0 (0x0).
The thread 'bgc-mikmxeue486 [61]' (0xd60) has exited with code 0 (0x0).
The thread 'bgc-mikmxeue486 [61]' (0xd60) has exited with code 0 (0x0).
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
Auto-attach to process '[3068] sqlservr.exe' on machine 'bgc-mikmxeue486'
succeeded.
'sqlservr.exe' (Managed): Loaded 'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Binn\SqlAccess.dll', Skipped loading symbols. Module is
optimized and the debugger option 'Just My Code' is enabled.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.
dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\Syst
em.Transactions.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_MSIL\System.Security\2.0.0.0__b03f5f7f11d50a3a\System
.Security.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.
dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just M
y
Code' is enabled.
'sqlservr.exe' (Managed): Loaded 'SQL_UDP', No symbols loaded.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\Sy
stem.Web.Services.dll', No symbols loaded.
'sqlservr.exe' (Managed): Loaded
'C:\WINNT\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\S
ystem.Configuration.dll', No symbols loaded.
'sqlservr.exe' (Managed): Loaded 'WebserviceCLR', Symbols loaded.
A .NET Framework error occurred during execution of user defined routine or
aggregate 'CallWebservice':
System.InvalidOperationException: Cannot load dynamically generated
serialization assembly. In some hosting environments assembly load
functionality is restricted, consider using pre-generated serializer. Please
see inner exception for more information. --> System.IO.FileLoadException:
LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by
the host.
System.IO.FileLoadException:
at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean
fIntrospection)
at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence securityEvidence)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.C
ompileAssemblyFromSourceBatch(CompilerPa
rameters options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerPa
rameter
..
System.InvalidOperationException:
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns,
CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[]
mappings, Type type)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at WebserviceCLR.wsslib.Library...
No rows affected.
(0 row(s) returned)
Finished running sp_executesql.
A first chance exception of type 'System.InvalidOperationException' occurred
in System.Xml.dll
The thread 'bgc-mikmxeue486 [61]' (0xd60) has exited with code 0 (0x0).
The program '[3068] [SQL] bgc-mikmxeue486: bgc-mikmxeue486' has exited with
code 0 (0x0).
The program '[3068] sqlservr.exe: Managed' has exited with code 259 (0x103)."examnotes" <Ludo@.discussions.microsoft.com> wrote in
news:825F081A-11D6-4D36-8C9A-F8B4AEA96CE5@.microsoft.com:

> Hi, I want to create following procedure to call a webservice. build
> ok execution not ok.
> When i do it in a seperated program it works. in the clr procedure
> not. It always end with 'System.InvalidOperationException' occurred
> in System.Xml.dll
> Can some one help me.
>
[snip]

> In some hosting
> environments assembly load functionality is restricted, consider using
> pre-generated serializer. Please see inner exception for more
> information. --> System.IO.FileLoadException: LoadFrom(), LoadFile(),
> Load(byte[]) and LoadModule() have been disabled by the host.
> System.IO.FileLoadException:
As the error says, SQLCLR doesn't allow you to load a dynamically
generated assembly (which happens when you do web-services). You need to
sgen the proxy code into a dll and catalogue that assembly in SQL
Server.
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb@.no-spam.develop.com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********

CLR problems

I have created a CLR stored procedure. Now I am trying to access that
CLR sproc from another stored procedure. When I try to create the
second sproc, I get the message:
Cannot add rows to sysdepends for the current object because it depends
on the missing object <<whatever>>.
Any ideas on what I'm doing wrong? I let Visual Studio deploy the
assembly and create the first stored procedure.
Thanks,
JoeHello Jmnd,

> I have created a CLR stored procedure. Now I am trying to access that
> CLR sproc from another stored procedure. When I try to create the
> second sproc, I get the message:
How do you mean "access that CLR sproc?" Are you calling it with T-SQL's
EXEC?
Thank you,
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||Jmnd (jnedumgottil@.gmail.com) writes:
> I have created a CLR stored procedure. Now I am trying to access that
> CLR sproc from another stored procedure. When I try to create the
> second sproc, I get the message:
> Cannot add rows to sysdepends for the current object because it depends
> on the missing object <<whatever>>.
<<whatever>>? Is that the name of your CLR procedure, or the name of
something else?

> Any ideas on what I'm doing wrong? I let Visual Studio deploy the
> assembly and create the first stored procedure.
Obviously Visual Studio did not create the procedure as you intended. Or
you are creating your T-SQL procedure in another database - or schema -
that you indended. How about using the Object Explorer to see what is in
that database?
Personally, I prefer to create CLR objects without Visual Studio. VS is
just so completely confusing. How difficult is it really to compile a
C# or VB program from the command line, saying CREATE ASSEMBLY, and then
CREATE PROCEDURE EXTERNAL NAME?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Sorry, I will clarify. I was trying to access the stored procedure
using T-SQL "EXEC" command. And I tried using regular command lines,
after I ran into issues. I used the "Create Procedure External Name"
(which I modified by pulling the script from the existing CLR Stored
Procedure). However, when I tried to run the create script on the
second stored procedure (the one that calls the CLR sproc), I was still
getting the same error:
Cannot add rows to sysdepends for the current object because it depends
on the missing object <<my CLR stored procedure>>.
The CLR sproc is showing up in SQL Management Studio. And I can call
it - I ran a test script on it. However, this other sproc cannot call
the CLR one. Is this a permissions issue?
Thanks again for your help.
Joe|||Jmnd (jnedumgottil@.gmail.com) writes:
> Sorry, I will clarify. I was trying to access the stored procedure
> using T-SQL "EXEC" command. And I tried using regular command lines,
> after I ran into issues. I used the "Create Procedure External Name"
> (which I modified by pulling the script from the existing CLR Stored
> Procedure). However, when I tried to run the create script on the
> second stored procedure (the one that calls the CLR sproc), I was still
> getting the same error:
> Cannot add rows to sysdepends for the current object because it depends
> on the missing object <<my CLR stored procedure>>.
> The CLR sproc is showing up in SQL Management Studio. And I can call
> it - I ran a test script on it. However, this other sproc cannot call
> the CLR one. Is this a permissions issue?
No. More likely a trivial spelling errors. (Happens in the best families.)
When you look in Mgmt Studio, where does the T-SQL procedure appear?
(The message you get is not an error message, and the procedure is still
created. Which it also says in the message.)
If you are still , please post the T-SQL procedure, as well as
the T-SQL statements to create the CLR proc.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hello Erland,
I agree that its possible that it's something trivial, but it might not be.
We might be missing an assembly, or the called proc might not have been cata
loged.
Or somebody tinkered with the visibility of an assembly, or its a versioning
problem, etc.
Jmnd, here's a simple example of what I think you are trying to do. If so,
this should work. If not, please feel to contact me off-line for follow up.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CalledStoredProcedure()
{
SqlCommand cmd = new SqlCommand("select 'Hello from the called proc'");
SqlContext.Pipe.ExecuteAndSend(cmd);
}
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CallingStoredProcedure()
{
SqlCommand cmd = new SqlCommand("select 'Hello from calling proc';
exec dbo.CalledStoredProcedure");
SqlContext.Pipe.ExecuteAndSend(cmd);
}
};
test with exec dbo.CallingStoredProcedure
I do agree with Erland, posting the code would help much.
Thank you,
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||Thanks for the input so far. I will double-check to make sure there
are no typos
========================================
================
here's my CLR procedure code in C#:
========================================
================
using System;
using System.Text;
using System.Collections.Generic;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
public class QueryBuilder
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void buildIndividualSummaryQuery(
....
/*parameter list*/
....
)
{
QueryBuilder ci = new QueryBuilder();
ci.addSelect("IND_F", "DATE", "CAL_MONTH_YR");
ci.addSelect("DATE_D", "DATE", "FSCL_MONTH_YR",
"FiscalMonthYr", "MAX");
ci.addSelect("IND_F", "I", "TOTAL_IND", "TotalCount", "SUM");
/* This calls another method in the same class */
string sqlString = ci.buildIndividualReportsQuery(
/*params*/ );
SqlContext.Pipe.Send("SqlString=" + sqlString);
SqlConnection connection = new SqlConnection("context
connection=true");
connection.Open();
SqlCommand command = new SqlCommand(sqlString, connection);
SqlDataReader reader = command.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
connection.Close();
}
}
========================================
================
Here's how I created the Stored Procedure wrapper:
========================================
================
USE [CustomerIntelligence]
GO
IF OBJECT_ID ( 'buildIndividualSummaryQuery', 'P' ) IS NOT NULL
DROP PROCEDURE buildIndividualSummaryQuery;
GO
CREATE PROCEDURE [dbo].[buildIndividualSummaryQuery]
...
/*params*/
...
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [CI].[QueryBuilder].[buildIndividualSummaryQuery]
GO
========================================
====
Here's my stored procedure that calls the CLR procedure:
========================================
====
ET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF OBJECT_ID ( 'IndividualSummaryReport', 'P' ) IS NOT NULL
DROP PROCEDURE IndividualSummaryReport;
GO
CREATE PROCEDURE IndividualSummaryReport
...
/* parameter list */
...
AS
BEGIN
...
/* other extraneous code */
...
exec [buildIndividualSummaryQuery]
....
/* parameter list */
...
END
GO

CLR integration - Could not find Type '?' in assembly '?'.

Hi,

I'm new to Integration services and .Net programming but am trying to
create a dll that I can access from Sql server 2005.

The dll read's an xml file and carries out some processing. I've run
the code as an console app and it works fine.

I have created the assembly in sqlserver thus:

create assembly PinCodeLoader from
'C:\PinCodeLoader\PinCodeLoader\PinCodeLoader\bin\Debug\PinCodeLoader.dll'
with permission_set = external_access

But when I try to reference the assembly from a stored proc

create procedure dbo.interface_processPinCodefile(@.filename
nvarchar(1024))
as EXTERNAL name PinCodeLoader.PinCodeloader.Main

I get the following error:

Msg 6505, Level 16, State 1, Procedure interface_processPinCodefile,
Line 3
Could not find Type 'PinCodeloader' in assembly 'PinCodeLoader'.

I understand the context of the syntax should be
assembly_name.class_name.method_name. The first lines of the code in
the DLL are as follows

namespace PinCodeLoader
{
class PinCodeLoader
{
static void Main(string[] args)
{

Therefore assembly = PinCodeLoader, class_name = PinCodeLoader and
method_name = Main. Which should equal
EXTERNAL name PinCodeLoader.PinCodeloader.Main, I thought.

Has anybody come across this or can they offer any assistance?

Many thanks,

Paul

Hi, try to compile the .vb file with this command line:

csc.exe /t:library PinCodeLoader.bv (Put the correct name of the .vb file)

If this work look at the properties of the project and search for 'root namespace' (or something similar), and delete it, then try again compiling the entire solution from de IDE...

Good luck

Alejandro F.

|||

You need to include the namespace as well:

create procedure dbo.interface_processPinCodefile(@.filename
nvarchar(1024))
as EXTERNAL name PinCodeLoader.[PinCodeLoader.PinCodeloader].Main

However, you still won't be able to create your proc because SQL can't map nvarchar(1024) to the string array args.

|||

Thanks for your replies guys. I didn't actually try that method but found a way around it.

In my c# program I removed the reference to a namespace, as I was told it's not really necessary and changed the code as follows.

public class PinCodeLoad

{

public static void Main(string filename,string datasource,Int32 timeout, string companyname)

{

So instead of using the args parameter I'm implictly defining them. Plus I preceded my class and method with public

I kept the stored proc as before.

I hope that helps anybody else.

Paul

CLR Defined Types

All read up and ready to create a database project only to find we dont have
"database" as an option for a project type.
Any clues why?
we have SQL 2005 running as well as running SQL reporting services.
ThanksIt's not available in every edition of VS. Only Pro and Team, I believe.
Are you running one of those?
If not, you still have options. Check out Niels Burglund's add-in tools
here:
http://sqljunkies.com/WebLog/nielsb...2/07/17967.aspx
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Sean" <Sean@.discussions.microsoft.com> wrote in message
news:C75961DB-0314-4629-B609-DF739B336FD2@.microsoft.com...
> All read up and ready to create a database project only to find we dont
> have
> "database" as an option for a project type.
> Any clues why?
> we have SQL 2005 running as well as running SQL reporting services.
> Thanks|||Pro Yes
Team No
I am thinking it was an option during the installation but whoever installed
it decided we didnt want all the features possible.
"Adam Machanic" wrote:

> It's not available in every edition of VS. Only Pro and Team, I believe.
> Are you running one of those?
> If not, you still have options. Check out Niels Burglund's add-in tools
> here:
> http://sqljunkies.com/WebLog/nielsb...2/07/17967.aspx
>
> --
> Adam Machanic
> Pro SQL Server 2005, available now
> http://www.apress.com/book/bookDisplay.html?bID=457
> --
>
> "Sean" <Sean@.discussions.microsoft.com> wrote in message
> news:C75961DB-0314-4629-B609-DF739B336FD2@.microsoft.com...
>
>

Wednesday, March 7, 2012

Close to quit working with VS 2005 and SQL Express (Cannot Create Database)

About 2 months ago, with great interest installed VS 2005 beta on my local Windows XP Pro. The SQL Express is running.

I cannot work FULLY on starter kits like Personal Web Site SK or Community SK. I create a new web site based on the Community SK. I can successfully bring up ASP.NET configuration, create roles, create users etc. When I look in the App_Data folder there is no ASPNET.MDF database. Where is this getting created?

2) Do we have permissions to create a SQL Database from VS 2005 Beta? I assume not, because at MSDN, there are generic SQL scripts for adding tables to Personal Web site SK and Community SK. For example, a start a new web ASP.NET web site. When I go to add new item, choose SQL Database, I get this error (see below). I am looking for documentation of SQL Express, I don't find any.

With very little time available after work, wife and kids, I am spending tons of hours looking to solve these issues (User Instance, Password Quality and this Access Denied) looking at MSDN, Forums etc. I agree that VS 2005 is a great product and there are great tutorials for VS 2005 both at Microsoft and other places (www.learningvisualstudio.net)

But if I cannot create SQL Databases, from VS 2005 interface, what is the use of going ahead and trying to learn these tools?

If somebody has specific answers or links that can resolve the above issues, please post here. If you have similar difficulties and how you overcame them, post them here. Thanks.
================================

Directory lookup for the file D:\Documents and Settings\<local computer name>\my documents\visual studio 2005\WebSites\Lesson07\App_Data\Customers.mdf” failed with the operating system error 5 (Access Denied).

CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

User does not have permission to alter database ‘4BE36399-4C49-4103-963D-7F34626E3914’ or the database does not exist.

ALTER DATABASE statement failed.

User does not have permission to alter database ‘4BE36399-4C49-4103-963D-7F34626E3914’ or the database does not exist.

ALTER DATABASE ‘4BE36399-4C49-4103-963D-7F34626E3914’ does not exist. Use sp_helpdb to show available databases.


=================================

There are two ways you can create databases. As you note, the MDF should be in the data folder. However, if you are running SSE with a UserInstance token in the connection string, then you are running SSE under your own account and you are full-on admin and can do anything you want. In this scenario, you can be logged on as admin or a normal user.

If you are connecting to SSE in the main instance, and you are running as a normal user, you might run into the situation you're describing.

If you get a copy of SSEUtil from the web (search for it), you will find it's a great way to figure out what's going on. It's like SQLCmd, but a lot friendlier. And, it works witih both SSE in the main instance and when it runs under your user account as a normal user.

In order, the things to check are:

1.) is SSE running?
2.) are you working in USERInstance mode or normal?
3.) Can you use SSEUtil to connect to and create databases.