Showing posts with label adding. Show all posts
Showing posts with label adding. Show all posts

Friday, March 9, 2012

Error connecting to the server

I am having a problem adding a new server or going into my previously registered servers.

I was using Sql express and now using the full version of SQL 2005.

When I try to coonect to a server, In the server type I choose Database Engine
Server name I typed in LOCALHOST\SQLEXPRESS, no names show in the
dropdown for server, leave use windows authentication selected. then hit the
advanced button and change the network library to shared memory, hit test
button and get this error:

"An error has occurred while establishing a connection to the server. when
connecting to sql server 2005, this failure may be caused by the fact that
under the default settings sql server does not allow remote connections.
(provider: shared memory provider, error: 36 - the shared memory dll used to
to connect to 2000 was not found)"

any input would be appreciated. thanks.

Are you connecting to the Remote server or a Local server?|||local server|||
<connectionStrings><add name="ConnectionString" connectionString="Data Source=.\SQLSERVER;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient" /></connectionStrings>

SQLSERVER is the server Name of your SQL SERVER. Check the name of the server (by default its SQLSERVER)

OR (create a new connection string)

Create a new Page > Put a GridView on it > Click the right Top corner and select the "New data source" > Click "Database" in the step "Choose a Data Type > Click OK > Now when you click the Drop down, probably you will see your Data base name in it.

(you will see the database name with your connection strings when the connection strings in web.config are not valid)

1. If you see the Database name:

Click Next and select any Table from your Database> Click Next again Ok > Click Finish. Now when you open your Configuration File (i.e web.config) you will see a new Connection string with the server Name.

2. If you dont see the Database Name:

Click "New Connection" in the step "Choose your data Connection" > Choose "Microsoft SQL Server" type and click Continue > choose your SQL SERVER Name from the Drop down next to REFRESH button> Attach the DataBase to the server > Now you can create a Connection string to the server.

Happy coding!

|||

I cannot register a server in sql server Management Studio

and this is the error i get

New Server Registration

Testing the registered server failed. Verify the server name, login credentials, and database, and then click test again.

Additional Information

=>An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)(Microsoft Sql Server)

|||

Hi,

Please check if you have the correct Servername and Instance name of that specific server.

I suggest you create a .UDL file to test the connection with the following steps:

1. Create a normal Text file.
2. Rename it to .udl extension.
3. Double click on that file and a Data Link Properties dialog box will be show.
4. Select the provider and data source, specify username and password, and click the Test Connection button for test.

|||

When I Have Microsoft OLE DB Provider for OLAP Drivers, it returns these options in the data source name

dBASE Files|||

Hi,

Are you connecting to a OLAP service(like SQL Server analysis service)? If not, I would suggest you use OLE DB Provider for SQL Server or SQL Native Client instead.

You can choose them from the Provider tab in Data Link Properties dialog box.

Friday, February 24, 2012

Error Checking Issue

Hi All,

I have a stored procedure to which I am adding an error checking. Here is my stored procedure.

CREATE PROCEDURE usp_DBGrowth

AS

DECLARE @.dbsize DEC(15,2)
DECLARE @.logsize DEC(15,2)
DECLARE @.dbname SYSNAME
DECLARE @.dbsizestr NVARCHAR(500)
DECLARE @.logsizestr NVARCHAR(500)
DECLARE @.totaldbsize DEC(15,2)
DECLARE @.dbid SMALLINT

DECLARE dbnames_cursor CURSOR
FOR
SELECT name, dbid
FROM dbo.sysdatabases

OPEN dbnames_cursor

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid
WHILE @.@.FETCH_STATUS = 0
BEGIN

SET @.dbsizestr = 'SELECT @.dbsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 1'

EXECUTE sp_executesql @.dbsizestr, N'@.dbsize decimal(15,2) output', @.dbsize output
PRINT @.dbsize

SET @.logsizestr = 'SELECT @.logsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 2'


EXECUTE sp_executesql @.logsizestr, N'@.logsize decimal(15,2) output', @.logsize output
PRINT @.logsize

SET @.totaldbsize = LTRIM(STR((@.dbsize + @.logsize)*8/1024,15,2))
PRINT @.totaldbsize

BEGIN TRANSACTION

IF @.dbid IN (SELECT dbid FROM dbo.sysdatabases) AND
@.dbid NOT IN (SELECT dbid FROM dbo.databaseoriginalsize)

INSERT INTO databaseoriginalsize (dbid, dbname, dbsize, updatedate) VALUES (@.dbid, @.dbname, @.totaldbsize, getdate())

IF @.@.ERROR <> 0
ROLLBACK TRANSACTION
ELSE

COMMIT TRANSACTION

BEGIN TRANSACTION

INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (5, getdate(), 25)
IF @.@.ERROR <> 0
ROLLBACK TRANSACTION
ELSE

COMMIT TRANSACTION


FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid

END

CLOSE dbnames_cursor
DEALLOCATE dbnames_cursor

dbid column in the databasesize table is a primary key, so I when I try to insert records with the same dbid, I can an error message that duplicate row can't be inserted. That is fine, however, when I query databasesize table, there are 4 records with the dbid 5. With the error checking I have I thought I shouldn't get any records in the table, since there is an error transaction should be rolled back. Two questions:
Can you tell me what I am doing wrong?
Also, I need to add error checking after execute sp_executesql statement. Any suggestions?Take a look at the sp_executesql entry in Books Online for detailed info, but there is an error code returned that can be used as a start for error handling after the call [Return Code Values 0 (success) or 1 (failure)]

Also, I am confused about dbid - if it is, in fact, a primary key, you should not be able to add a duplicate row.

Do you actually have the column DEFINED as a primary key, or are you just saying that it IS a "primary key" in concept?

*edit*
Keep in mind that the return code values (success/failure) are pretty much (as you might expect) binary. The statement executed or it did not. If you need more robust error reporting, consider using a stored procedure and return codes/variables from it that may be more descriptive regarding the error encountered. If you go the stored proc route, heavily consider the use of the RAISERROR logic so that the calling procedure (or stack thereof) will handle the lower-level failure correctly.|||It is defined as a primary key.|||So what you are saying then, is that in a table with a defined primary key of the dbid, SQL Server is allowing you to insert a row with a duplicate key? And not one, but many?

Hmmmm...never heard of that one before...did not think it was possible (in fact, I still don't - there's gotta be something else we are miscommunicating about here)...though I inadvertently have tried it on many, many occasions.

The very definition of a primary key precludes the situation you describe.

Humor me and check and make sure that column is defined in the table definition as a primary key.

The reason I ask is because if I understand your situation and question correctly, your error handling should not be an issue of success or failure. If you define a column in a table as belonging to the table's primary key, you CANNOT enter either a duplicate nor NULL value in that (or those) column(s). This is enforced at the SQL Server level, not in error handling code.|||Sorry, my fault. This table has a composite primary key - updatedate and dbsize columns.|||ok, clearing that up then, you now know why you have your duplicate dbid entries, correct? If it's not part of the primary key and not part of a UNIQUE-constrained index, then you won't get an error on the insert.

I am still confusicated by how you are getting a duplicate record error on the insert to the databasesize table anyway. Your GETDATE() used in the insert statement should pretty much always return a different, unique value (at least the milliseconds should make it so - unless you are looping VERY, VERY quickly ;) )|||They are not really duplicates, I've realized it now. The difference is in the milliseconds. So technically these records are not duplicates.

I modified the error checking a little bit and now I am getting this error message:

SP
ALTER PROCEDURE usp_DBGrowth

AS

DECLARE @.dbsize DEC(15,2)
DECLARE @.logsize DEC(15,2)
DECLARE @.dbname SYSNAME
DECLARE @.dbsizestr NVARCHAR(500)
DECLARE @.logsizestr NVARCHAR(500)
DECLARE @.totaldbsize DEC(15,2)
DECLARE @.dbid SMALLINT
declare @.myerror int

DECLARE dbnames_cursor CURSOR
FOR
SELECT name, dbid
FROM dbo.sysdatabases

OPEN dbnames_cursor

BEGIN TRANSACTION

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid
WHILE @.@.FETCH_STATUS = 0
BEGIN

SET @.dbsizestr = 'SELECT @.dbsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 1'

EXECUTE sp_executesql @.dbsizestr, N'@.dbsize decimal(15,2) output', @.dbsize output
PRINT @.dbsize

SET @.logsizestr = 'SELECT @.logsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 2'


EXECUTE sp_executesql @.logsizestr, N'@.logsize decimal(15,2) output', @.logsize output
PRINT @.logsize

SET @.totaldbsize = LTRIM(STR((@.dbsize + @.logsize)*8/1024,15,2))
PRINT @.totaldbsize

IF @.dbid IN (SELECT dbid FROM dbo.sysdatabases) AND
@.dbid NOT IN (SELECT dbid FROM dbo.databaseoriginalsize)

INSERT INTO databaseoriginalsize (dbid, dbname, dbsize, updatedate) VALUES (@.dbid, @.dbname, @.totaldbsize, getdate())

set @.myerror = @.@.error
print @.myerror
IF @.@.ERROR <> 0 goto handle_errors
return(1)

--INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (@.dbid, getdate(), @.totaldbsize)
INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (5, getdate(), 45.0)

set @.myerror = @.@.error
print @.myerror
IF @.@.ERROR <> 0 goto handle_errors
return(1)

commit transaction

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid

handle_errors:
rollback transaction
print 'error occured'

END

CLOSE dbnames_cursor
DEALLOCATE dbnames_cursor

Error message:

7328.00
648.00
62.31
0
Server: Msg 266, Level 16, State 2, Procedure usp_DBGrowth, Line 60
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 0, current count = 1.

How can I fix it?

Also, Do you have any examples of sp with cursors, dynamic sql and error checking all in one sp? That would really help me.

Thanks.|||IF @.@.ERROR <> 0 goto handle_errors
return(1)
If everything is OK you just return, without commiting the transaction. You should move the return statement a bit down in your code.

Futhermore I would youse a begin...else...end structure instead of your label and goto. Kind of:
IF @.@.ERROR = 0
BEGIN
-- Handle successful condition
...
COMMIT TRANSACTION
END ELSE
BEGIN
-- Handle error condition
...
ROLLBACK TRANSACTION
END
RETURN()|||for how to handle errors in sql:

http://www.sommarskog.se/error-handling-II.html
http://www.sommarskog.se/error-handling-I.html|||roac,
I've tried what you have suggested and I am getting the following error:

7328.00
648.00
62.31
Server: Msg 3902, Level 16, State 1, Procedure usp_DBGrowth, Line 58
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
Server: Msg 3903, Level 16, State 1, Procedure usp_DBGrowth, Line 75
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.

Here is the sp:

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

ALTER PROCEDURE usp_DBGrowth

AS

DECLARE @.dbsize DEC(15,2)
DECLARE @.logsize DEC(15,2)
DECLARE @.dbname SYSNAME
DECLARE @.dbsizestr NVARCHAR(500)
DECLARE @.logsizestr NVARCHAR(500)
DECLARE @.totaldbsize DEC(15,2)
DECLARE @.dbid SMALLINT

DECLARE dbnames_cursor CURSOR
FOR
SELECT name, dbid
FROM dbo.sysdatabases

OPEN dbnames_cursor

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid
WHILE @.@.FETCH_STATUS = 0
BEGIN

SET @.dbsizestr = 'SELECT @.dbsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 1'

EXECUTE sp_executesql @.dbsizestr, N'@.dbsize decimal(15,2) output', @.dbsize output
PRINT @.dbsize

SET @.logsizestr = 'SELECT @.logsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 2'


EXECUTE sp_executesql @.logsizestr, N'@.logsize decimal(15,2) output', @.logsize output
PRINT @.logsize

SET @.totaldbsize = LTRIM(STR((@.dbsize + @.logsize)*8/1024,15,2))
PRINT @.totaldbsize

if @.@.error = 0
begin
IF @.dbid IN (SELECT dbid FROM dbo.sysdatabases) AND
@.dbid NOT IN (SELECT dbid FROM dbo.databaseoriginalsize)

INSERT INTO databaseoriginalsize (dbid, dbname, dbsize, updatedate) VALUES (@.dbid, @.dbname, @.totaldbsize, getdate())

commit transaction
end
else
begin
rollback transaction
end

if @.@.error = 0
begin

INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (@.dbid, getdate(), @.totaldbsize)

commit transaction
end
else
begin
rollback transaction
end


FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid

END

CLOSE dbnames_cursor
DEALLOCATE dbnames_cursor


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Can you please review it and let me know where my problem is?

Thanks.|||There is no BEGIN TRANSACTION in your stored procedure. You can't commit or rollback a transaction that does not exist.|||Do I need to change begin to begin transaction? Or I need to do something else?|||No, you need that "begin" there if you want to execute the block of code between your current BEGIN and END like you are now.

What you need to do is to put a BEGIN TRANSACTION in your code at the point at which you want your logical transaction to begin. It might be right AFTER the BEGIN in your code...it depends on where you want your logical transaction to start. I don't think ROAC was telling you to remove your BEGIN TRANSACTION code in your original post of your code...just how to handle the error section.

I actually think your original code posted was closer to the way I would recommend than the current iteration. I'm just not sure what the RETURN(1) is supposed to signify in your original code...you do realize it returns you to the caller with an exit code of 1 if each update is successful, right? I don't THINK that is what you want to do.

Try this:.
.
.
.
INSERT INTO databaseoriginalsize (dbid, dbname, dbsize, updatedate) VALUES (@.dbid, @.dbname, @.totaldbsize, getdate())

set @.myerror = @.@.error
print @.myerror
IF @.myerror <> 0 goto handle_errors

--INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (@.dbid, getdate(), @.totaldbsize)
INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (5, getdate(), 45.0)

set @.myerror = @.@.error
print @.myerror
IF @.myerror <> 0 goto handle_errors

commit transaction

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid
END

return(0)

handle_errors:
rollback transaction
print 'error occured'
return(1)

CLOSE dbnames_cursor
DEALLOCATE dbnames_cursor
.
.
.
Your original code just didn't flow correctly, IMHO...|||TallCowboy0614,

I've tried that and here is the message I get once I execute my sp.

7328.00
648.00
62.31
0

(1 row(s) affected)

0
1408.00
640.00
16.00
0

(1 row(s) affected)

0
Server: Msg 3902, Level 16, State 1, Procedure usp_DBGrowth, Line 68
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
640.00
648.00
10.06
0

(1 row(s) affected)

Now, it looks like although I got this error message all the records were committed. Can you tell me what to do with it?|||You are trying to commit/Rollback 2 times and beginning the transaction only one time... thats the problem.

My sugession is to merge the both @.@.Error = 0 blocks into one OR write BEGIN TRANSACTION after first @.@.Error = 0 block (which is just avoid the error but it is not recommended to do this way...)

I think it is helpful.

Cheers
--Riaz

TallCowboy0614,

I've tried that and here is the message I get once I execute my sp.

7328.00
648.00
62.31
0

(1 row(s) affected)

0
1408.00
640.00
16.00
0

(1 row(s) affected)

0
Server: Msg 3902, Level 16, State 1, Procedure usp_DBGrowth, Line 68
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
640.00
648.00
10.06
0

(1 row(s) affected)

Now, it looks like although I got this error message all the records were committed. Can you tell me what to do with it?|||Sorry, I should've posted my latest version of sp since I made the changes that TallCowboy0614 recommended.

Here what it looks like now:

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

ALTER PROCEDURE usp_DBGrowth

AS

DECLARE @.dbsize DEC(15,2)
DECLARE @.logsize DEC(15,2)
DECLARE @.dbname SYSNAME
DECLARE @.dbsizestr NVARCHAR(500)
DECLARE @.logsizestr NVARCHAR(500)
DECLARE @.totaldbsize DEC(15,2)
DECLARE @.dbid SMALLINT
DECLARE @.myerror int

DECLARE dbnames_cursor CURSOR
FOR
SELECT name, dbid
FROM dbo.sysdatabases

OPEN dbnames_cursor

--BEGIN TRANSACTION

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid
WHILE @.@.FETCH_STATUS = 0
BEGIN

SET @.dbsizestr = 'SELECT @.dbsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 1'

EXECUTE sp_executesql @.dbsizestr, N'@.dbsize decimal(15,2) output', @.dbsize output
PRINT @.dbsize

SET @.logsizestr = 'SELECT @.logsize = sum(convert(dec(15,2),size))
FROM ' + @.dbname + '.dbo.sysfiles
WHERE fileid = 2'


EXECUTE sp_executesql @.logsizestr, N'@.logsize decimal(15,2) output', @.logsize output
PRINT @.logsize

SET @.totaldbsize = LTRIM(STR((@.dbsize + @.logsize)*8/1024,15,2))
PRINT @.totaldbsize

begin transaction
IF @.dbid IN (SELECT dbid FROM dbo.sysdatabases) AND
@.dbid NOT IN (SELECT dbid FROM dbo.databaseoriginalsize)

INSERT INTO databaseoriginalsize (dbid, dbname, dbsize, updatedate) VALUES (@.dbid, @.dbname, @.totaldbsize, getdate())

set @.myerror = @.@.error
print @.myerror
if @.myerror <>0 goto handle_errors

INSERT INTO databasesize (dbid, updatedate, dbsize) VALUES (@.dbid, getdate(), @.totaldbsize)
set @.myerror = @.@.error
print @.myerror
if @.myerror <> 0 goto handle_errors
commit transaction

FETCH NEXT FROM dbnames_cursor INTO @.dbname, @.dbid

END
return(0)

handle_errors:
rollback transaction
print 'error occurred'
return(1)

CLOSE dbnames_cursor
DEALLOCATE dbnames_cursor

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

And this is the error on execution:

7328.00
648.00
62.31
0

(1 row(s) affected)

0
1408.00
640.00
16.00
0

(1 row(s) affected)

0
Server: Msg 3902, Level 16, State 1, Procedure usp_DBGrowth, Line 68
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
640.00
648.00
10.06
0

(1 row(s) affected)|||OK, the code looks good to me, so I think there is something else involved. Perhaps implicit transactions getting in the way, or something similar?

Anyway, try printing the contents of @.@.TRANCOUNT before and after your BEGIN TRAN and COMMIT TRAN statements, as well as after (and maybe even before) the INSERTS within your transaction block.

Somewhere the transaction is being lost for some reason.

Wednesday, February 15, 2012

error adding Windows group security to database

I'm trying to add a Windows 2000 group to a database with
db_owner rights using the following:
sp_adduser 'MyDomain\sql-admins', 'sql-admins', 'db_owner'
GO
--
I'm encountering the following error:
Server: Msg 15007, Level 16, State 1, Procedure
sp_adduser, Line 15
The login 'MyDomain\sql-admins' does not exist.
--
The login does exist though.
Any help is appreciated.sp_adduser is for backwards compatibility only - try using
sp_grantdbaccess and sp_addrolemember. You can find more information
on these procedures in books online.
You can add a Windows group to the db_owner group using:
EXEC sp_addrolemember 'db_owner', 'YourDomain\YourGroup'
-Sue
On Fri, 21 May 2004 12:42:23 -0700, "Andy"
<anonymous@.discussions.microsoft.com> wrote:

>I'm trying to add a Windows 2000 group to a database with
>db_owner rights using the following:
>--
>sp_adduser 'MyDomain\sql-admins', 'sql-admins', 'db_owner'
>GO
>--
>I'm encountering the following error:
>--
>Server: Msg 15007, Level 16, State 1, Procedure
>sp_adduser, Line 15
>The login 'MyDomain\sql-admins' does not exist.
>--
>The login does exist though.
>Any help is appreciated.|||Thanks Sue, that worked.
However, I'm trying to use the function in an IF statement:
IF @.@.SERVERNAME = 'MyServer'
BEGIN
sp_revokedbaccess 'MyGroup'
GO
sp_grantdbaccess 'MyDomain\MyGroup', 'MyGroup'
GO
sp_addrolemember 'db_owner', 'MyGroup'
GO
END
I get the following error:
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'sp_revokedbaccess'.
I can execute the commands fine if they're not in the
BEGIN-END statement
Any ideas anyone?

>--Original Message--
>sp_adduser is for backwards compatibility only - try using
>sp_grantdbaccess and sp_addrolemember. You can find more
information
>on these procedures in books online.
>You can add a Windows group to the db_owner group using:
>EXEC sp_addrolemember 'db_owner', 'YourDomain\YourGroup'
>-Sue
>On Fri, 21 May 2004 12:42:23 -0700, "Andy"
><anonymous@.discussions.microsoft.com> wrote:
>
with[vbcol=seagreen]
admins', 'db_owner'[vbcol=seagreen]
>.
>|||Andy,
Try executing the block using something like:
BEGIN
exec sp_revokedbaccess 'MyGroup'
exec sp_grantdbaccess 'MyDomain\MyGroup', 'MyGroup'
exec sp_addrolemember 'db_owner', 'MyGroup'
END
-Sue
On Mon, 24 May 2004 07:45:42 -0700, "Andy"
<anonymous@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Thanks Sue, that worked.
>However, I'm trying to use the function in an IF statement:
>IF @.@.SERVERNAME = 'MyServer'
> BEGIN
> sp_revokedbaccess 'MyGroup'
> GO
> sp_grantdbaccess 'MyDomain\MyGroup', 'MyGroup'
> GO
> sp_addrolemember 'db_owner', 'MyGroup'
> GO
> END
>I get the following error:
>Server: Msg 170, Level 15, State 1, Line 3
>Line 3: Incorrect syntax near 'sp_revokedbaccess'.
>I can execute the commands fine if they're not in the
>BEGIN-END statement
>Any ideas anyone?
>
>information
>with
>admins', 'db_owner'|||It worked.
My SQL is appearently a bit rusty, thanks again.
-Andy

>--Original Message--
>Andy,
>Try executing the block using something like:
>BEGIN
> exec sp_revokedbaccess 'MyGroup'
> exec sp_grantdbaccess 'MyDomain\MyGroup', 'MyGroup'
> exec sp_addrolemember 'db_owner', 'MyGroup'
> END
>-Sue
>On Mon, 24 May 2004 07:45:42 -0700, "Andy"
><anonymous@.discussions.microsoft.com> wrote:
>
statement:[vbcol=seagreen]
using[vbcol=seagreen]
more[vbcol=seagreen]
>.
>|||Your welcome...glad it's working for you now.
Don't think it's due to your SQL being rusty...a lot of
people get burned on both the exec and the go issues.
You need to use exec for executing a stored procedure when
the command is not the first command in a batch.
GO delimits a batch. When you put GO keywords inside
Begin...End blocks, the End is not sent to the server in the
same batch with the Begin so it's interpreted as a missing
END. You end up with the same effects you get as if you were
missing the closing parenthesis.
-Sue
On Mon, 24 May 2004 11:44:05 -0700,
<anonymous@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>It worked.
>My SQL is appearently a bit rusty, thanks again.
>-Andy
>
>statement:
>using
>more

Error Adding User

Hello, I have a problem with adding users to a database using sp_adduser.
The user I'm using is a member of db_owner but I receive the following error:
sp_adduser adam, adam, DEFAULT_USERS
Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
User does not have permission to perform this action
It only works when I log in as a System Administrator. However if I login as
the db_owner account which generates the above error and run the following:
exec sp_grantdbaccess adam
exec sp_addrolemember DEFAULT_USERS, adam
It works fine. The problem is that it is a piece of 3rd party software that
is trying to add the users and won't be easy to get them to change it as
sp_adduser should work. Also I don't want them logging in as System
Administrator when I could try and fix it. Any ideas?
One solution is to drop the user from the database, and then make its login
the owner of the database:
sp_dropuser 'the_user'
go
use the_database
go
sp_changedbowner 'the_login'
go
Linchi
"Adam Sankey" wrote:

> Hello, I have a problem with adding users to a database using sp_adduser.
> The user I'm using is a member of db_owner but I receive the following error:
> sp_adduser adam, adam, DEFAULT_USERS
> Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
> User does not have permission to perform this action
> It only works when I log in as a System Administrator. However if I login as
> the db_owner account which generates the above error and run the following:
> exec sp_grantdbaccess adam
> exec sp_addrolemember DEFAULT_USERS, adam
> It works fine. The problem is that it is a piece of 3rd party software that
> is trying to add the users and won't be easy to get them to change it as
> sp_adduser should work. Also I don't want them logging in as System
> Administrator when I could try and fix it. Any ideas?
>
|||Thanks very much that worked fine - I still don't understand why I had this
problem in the first place. Do you have an insight in to this?
Thanks again
Adam
"Linchi Shea" wrote:
[vbcol=seagreen]
> One solution is to drop the user from the database, and then make its login
> the owner of the database:
> sp_dropuser 'the_user'
> go
> use the_database
> go
> sp_changedbowner 'the_login'
> go
> Linchi
> "Adam Sankey" wrote:

Error Adding User

Hello, I have a problem with adding users to a database using sp_adduser.
The user I'm using is a member of db_owner but I receive the following error:
sp_adduser adam, adam, DEFAULT_USERS
Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
User does not have permission to perform this action
It only works when I log in as a System Administrator. However if I login as
the db_owner account which generates the above error and run the following:
exec sp_grantdbaccess adam
exec sp_addrolemember DEFAULT_USERS, adam
It works fine. The problem is that it is a piece of 3rd party software that
is trying to add the users and won't be easy to get them to change it as
sp_adduser should work. Also I don't want them logging in as System
Administrator when I could try and fix it. Any ideas?One solution is to drop the user from the database, and then make its login
the owner of the database:
sp_dropuser 'the_user'
go
use the_database
go
sp_changedbowner 'the_login'
go
Linchi
"Adam Sankey" wrote:
> Hello, I have a problem with adding users to a database using sp_adduser.
> The user I'm using is a member of db_owner but I receive the following error:
> sp_adduser adam, adam, DEFAULT_USERS
> Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
> User does not have permission to perform this action
> It only works when I log in as a System Administrator. However if I login as
> the db_owner account which generates the above error and run the following:
> exec sp_grantdbaccess adam
> exec sp_addrolemember DEFAULT_USERS, adam
> It works fine. The problem is that it is a piece of 3rd party software that
> is trying to add the users and won't be easy to get them to change it as
> sp_adduser should work. Also I don't want them logging in as System
> Administrator when I could try and fix it. Any ideas?
>|||Thanks very much that worked fine - I still don't understand why I had this
problem in the first place. Do you have an insight in to this?
Thanks again
Adam
"Linchi Shea" wrote:
> One solution is to drop the user from the database, and then make its login
> the owner of the database:
> sp_dropuser 'the_user'
> go
> use the_database
> go
> sp_changedbowner 'the_login'
> go
> Linchi
> "Adam Sankey" wrote:
> > Hello, I have a problem with adding users to a database using sp_adduser.
> > The user I'm using is a member of db_owner but I receive the following error:
> >
> > sp_adduser adam, adam, DEFAULT_USERS
> >
> > Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
> > User does not have permission to perform this action
> >
> > It only works when I log in as a System Administrator. However if I login as
> > the db_owner account which generates the above error and run the following:
> >
> > exec sp_grantdbaccess adam
> > exec sp_addrolemember DEFAULT_USERS, adam
> >
> > It works fine. The problem is that it is a piece of 3rd party software that
> > is trying to add the users and won't be easy to get them to change it as
> > sp_adduser should work. Also I don't want them logging in as System
> > Administrator when I could try and fix it. Any ideas?
> >

Error Adding User

Hello, I have a problem with adding users to a database using sp_adduser.
The user I'm using is a member of db_owner but I receive the following error
:
sp_adduser adam, adam, DEFAULT_USERS
Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
User does not have permission to perform this action
It only works when I log in as a System Administrator. However if I login as
the db_owner account which generates the above error and run the following:
exec sp_grantdbaccess adam
exec sp_addrolemember DEFAULT_USERS, adam
It works fine. The problem is that it is a piece of 3rd party software that
is trying to add the users and won't be easy to get them to change it as
sp_adduser should work. Also I don't want them logging in as System
Administrator when I could try and fix it. Any ideas?One solution is to drop the user from the database, and then make its login
the owner of the database:
sp_dropuser 'the_user'
go
use the_database
go
sp_changedbowner 'the_login'
go
Linchi
"Adam Sankey" wrote:

> Hello, I have a problem with adding users to a database using sp_adduser.
> The user I'm using is a member of db_owner but I receive the following err
or:
> sp_adduser adam, adam, DEFAULT_USERS
> Server: Msg 15247, Level 16, State 1, Procedure sp_adduser, Line 35
> User does not have permission to perform this action
> It only works when I log in as a System Administrator. However if I login
as
> the db_owner account which generates the above error and run the following
:
> exec sp_grantdbaccess adam
> exec sp_addrolemember DEFAULT_USERS, adam
> It works fine. The problem is that it is a piece of 3rd party software tha
t
> is trying to add the users and won't be easy to get them to change it as
> sp_adduser should work. Also I don't want them logging in as System
> Administrator when I could try and fix it. Any ideas?
>|||Thanks very much that worked fine - I still don't understand why I had this
problem in the first place. Do you have an insight in to this?
Thanks again
Adam
"Linchi Shea" wrote:
[vbcol=seagreen]
> One solution is to drop the user from the database, and then make its logi
n
> the owner of the database:
> sp_dropuser 'the_user'
> go
> use the_database
> go
> sp_changedbowner 'the_login'
> go
> Linchi
> "Adam Sankey" wrote:
>

Error adding two OledbCommands to a package programatically

Hi,

I need to add two oledbcommand tranformations in my package.

i add the commands like this:

--

this.OledbCommand1 = this.dataflow.ComponentMetaDataCollection.New();

this.OledbCommand1.ComponentClassID = "DTSTransform.OleDBCommand.1";

this.OledbCommand1.Name = "ChangingColumnAttribute";

this.OledbCommand1.Description = "ChangingColumnAttribute";

CManagedComponentWrapper oledbinstance = this.OledbCommand1.Instantiate();

oledbinstance.ProvideComponentProperties();

this.OledbCommand2 = this.dataflow.ComponentMetaDataCollection.New();

this.OledbCommand2.ComponentClassID = "DTSTransform.OleDBCommand.1";

this.OledbCommand2.Description = "UpdateHistoryColumnAttribute";

OledbCommand2.Name = "OleDBCommand2";

CManagedComponentWrapper oledbinstance1 = this.OledbCommand2.Instantiate();

oledbinstance1.ProvideComponentProperties();

-

i get the following error message during package validation:

OnError
ErrorCode -1073451000
Source DataFlow
SubComponent DTS.Pipeline
Description The package contains two objects with the duplicate name of "compone
nt "OLE DB Command" (719)" and "component "OLE DB Command" (701)".

Please advice.

Look at setting "IdentificationString" for each of your items.|||

I get the following output for Identification Strings:

OledbCommand1 Component: "ChangingColumnAttribute" (701)

OledbCommand2 Component: "OLE DB Command" (723)

Regards,

Sriharsh

|||Do you need to add "this." to the line where you set the name for OLEDBCommand 2?|||

Adding "this" did not help.

Still get the following error message:

Description The package contains two objects with the duplicate name of "component "OLE DB Command" (723)" and "component "OLE DB Command" (701)".

-

this.OledbCommand1 = this.dataflow.ComponentMetaDataCollection.New();

this.OledbCommand1.ComponentClassID = "DTSTransform.OleDBCommand.1";

this.OledbCommand1.Name = "OledbCommand1";

this.OledbCommand1.Description = "ChangingColumnAttribute";

this.OledbCommand2 = this.dataflow.ComponentMetaDataCollection.New();

this.OledbCommand2.ComponentClassID = "DTSTransform.OleDBCommand.1";

this.OledbCommand2.Name = "OledbCommand2";

this.OledbCommand2.Description = "UpdateHistoryColumnAttribute";

Error Adding SQL Server to Active Directory

Hi,
I've just installed SQL 2000 SE on a server and specified seperate domain
accounts for the services to run under. Now when I go to the server
properties and the Active Directory tab to add the server to AD I get the
following error:
SQL Server Enterprise Manager could not add server '(local)' to Active
Directory. Error 22039: xpadsi.exe failed.
Anyone else had this problem?
Thanks - Dave.yes. did you ever work out how to fix it ?
"Dave Rhodes" wrote:

> Hi,
> I've just installed SQL 2000 SE on a server and specified seperate domain
> accounts for the services to run under. Now when I go to the server
> properties and the Active Directory tab to add the server to AD I get the
> following error:
> SQL Server Enterprise Manager could not add server '(local)' to Active
> Directory. Error 22039: xpadsi.exe failed.
> Anyone else had this problem?
> Thanks - Dave.
>
>

Error Adding SQL Server to Active Directory

Hi,
I've just installed SQL 2000 SE on a server and specified seperate domain
accounts for the services to run under. Now when I go to the server
properties and the Active Directory tab to add the server to AD I get the
following error:
SQL Server Enterprise Manager could not add server '(local)' to Active
Directory. Error 22039: xpadsi.exe failed.
Anyone else had this problem?
Thanks - Dave.yes. did you ever work out how to fix it ?
"Dave Rhodes" wrote:
> Hi,
> I've just installed SQL 2000 SE on a server and specified seperate domain
> accounts for the services to run under. Now when I go to the server
> properties and the Active Directory tab to add the server to AD I get the
> following error:
> SQL Server Enterprise Manager could not add server '(local)' to Active
> Directory. Error 22039: xpadsi.exe failed.
> Anyone else had this problem?
> Thanks - Dave.
>
>

Error Adding SQL Server to Active Directory

Hi,
I've just installed SQL 2000 SE on a server and specified seperate domain
accounts for the services to run under. Now when I go to the server
properties and the Active Directory tab to add the server to AD I get the
following error:
SQL Server Enterprise Manager could not add server '(local)' to Active
Directory. Error 22039: xpadsi.exe failed.
Anyone else had this problem?
Thanks - Dave.
yes. did you ever work out how to fix it ?
"Dave Rhodes" wrote:

> Hi,
> I've just installed SQL 2000 SE on a server and specified seperate domain
> accounts for the services to run under. Now when I go to the server
> properties and the Active Directory tab to add the server to AD I get the
> following error:
> SQL Server Enterprise Manager could not add server '(local)' to Active
> Directory. Error 22039: xpadsi.exe failed.
> Anyone else had this problem?
> Thanks - Dave.
>
>

Error Adding SQL Server Login Properties

Hello,
I have SQL 200 SP3 box that has a web app with a hard coded user; I
tried to re-add the user after it was deleted.
I now get the following error when trying to add the database access:
"Error 21002 [SQL-DMO] user 'unsername' already exists."
Any help would be greatly appreciated.
I fixed my issue by running the following:
use my_db;
go
sp_change_users_login AUTO_FIX, 'my_user'
go
Hulicat wrote:
> Hello,
> I have SQL 200 SP3 box that has a web app with a hard coded user; I
> tried to re-add the user after it was deleted.
> I now get the following error when trying to add the database access:
> "Error 21002 [SQL-DMO] user 'unsername' already exists."
>
> Any help would be greatly appreciated.

Error Adding SQL Server Login Properties

Hello,
I have SQL 200 SP3 box that has a web app with a hard coded user; I
tried to re-add the user after it was deleted.
I now get the following error when trying to add the database access:
"Error 21002 [SQL-DMO] user 'unsername' already exists."
Any help would be greatly appreciated.I fixed my issue by running the following:
use my_db;
go
sp_change_users_login AUTO_FIX, 'my_user'
go
Hulicat wrote:
> Hello,
> I have SQL 200 SP3 box that has a web app with a hard coded user; I
> tried to re-add the user after it was deleted.
> I now get the following error when trying to add the database access:
> "Error 21002 [SQL-DMO] user 'unsername' already exists."
>
> Any help would be greatly appreciated.

Error Adding Package Configurations After Removing Them

I have a package that used to have package configurations enabled, with a single XML file holding the configuration information. The configuration information was removed from the package (and "Enable Package Configurations" was left checked, although I'm not sure that is creating this problem).

Now trying to add a new configuration to the package. When I open the Package Configurations Organizer dialog box and select "Add...", I get the following error:
TITLE: Microsoft Visual Studio

An error occurred while a new configuration was being added.

ADDITIONAL INFORMATION:
The path is not of a legal form. (mscorlib)

BUTTONS:
OK
Anyone have any ideas what to do about this? I've looked at the XML for the package and can't see any improperly formed nodes or bad attribute settings or anything. Thoughts?

Dave Fackler

Did you ever get to the bottom of this Dave?

-Jamie

Error adding existing SSIS Package to new Project

Hi, All:

I am relatively new to SQL Server 2005 SSIS. I encountered the below error while trying to add an existing package to a newly created Project:

Failed to save package file <path_filename> with error 0x80029C4A "Error loading type library/DLL.".

If someone has encountered this error, please reply with a solution or suggestions.

Thanks.

Looks like installation error. What SQL components and Service Packs have you installed, and in which order? Is it 64-bit or 32-bit OS?|||

Actually, all of the SQL components are installed; however, there are no Service Packs installed. The OS is 32-bit.

Thanks for your reply.

|||

I have resolved this issue.

Thanks everyone.

Error adding Assembly to SQL 2005

I have a clr assembly that access the internet via Sockets and file access. This require me to set the Assembly permissions level to External.

There are lots of messages on the net regarding this issue. none have worked for me.

Currently I'm trying to install the assembly with "sign the assembly" checked, createing a strong name key file.

When I run the installation I get the following message from the server

"Create failed for SqlAssembly 'xxx'.(Microsoft.sqlServer.Smo)

an exception occured while executing a Transact-SQL statement or batch

(Microsoft.SqlServer.ConnectionInfo)

A severe error occured in the current command. The results, if any, should be discarded.

This is the messag I get.

The following link does not display any usefull information.

TITLE: Microsoft SQL Server Management Studio

Create failed for SqlAssembly 'KBTTriggers'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+SqlAssembly&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

A severe error occurred on the current command. The results, if any, should be discarded.
A severe error occurred on the current command. The results, if any, should be discarded. (Microsoft SQL Server, Error: 0)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476


BUTTONS:

OK

Hi,

I am getting the same error. Anyone please help me out on this issue.

Thanks,

Arun

|||

I resolved this issue.

please refer the link for more details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=194501&SiteID=1

Error adding Assembly to SQL 2005

I have a clr assembly that access the internet via Sockets and file access. This require me to set the Assembly permissions level to External.

There are lots of messages on the net regarding this issue. none have worked for me.

Currently I'm trying to install the assembly with "sign the assembly" checked, createing a strong name key file.

When I run the installation I get the following message from the server

"Create failed for SqlAssembly 'xxx'.(Microsoft.sqlServer.Smo)

an exception occured while executing a Transact-SQL statement or batch

(Microsoft.SqlServer.ConnectionInfo)

A severe error occured in the current command. The results, if any, should be discarded.

This is the messag I get.

The following link does not display any usefull information.

TITLE: Microsoft SQL Server Management Studio

Create failed for SqlAssembly 'KBTTriggers'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+SqlAssembly&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

A severe error occurred on the current command. The results, if any, should be discarded.
A severe error occurred on the current command. The results, if any, should be discarded. (Microsoft SQL Server, Error: 0)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476


BUTTONS:

OK

Hi,

I am getting the same error. Anyone please help me out on this issue.

Thanks,

Arun

|||

I resolved this issue.

please refer the link for more details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=194501&SiteID=1

Error adding an Account to a Profile for 'Database Mail'

Configuring...
- Create new account 'SQL Agent SMTP Account' for SMTP server {exchange
server}(Error)
Messages
â?¢ Unable to create new account SQL Agent SMTP Account for SMTP server
Microsoft.SqlServer.Management.SqlManagerUI.SQLiMailServer.
--
ADDITIONAL INFORMATION:
Create failed for MailAccount 'SQL Agent SMTP Account'.
(Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+MailAccount&LinkId=20476
--
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
--
Cannot insert the value NULL into column 'servername', table
'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
The statement has been terminated. (Microsoft SQL Server, Error: 515) {this
was filled in. Don't kow why it is saying it was NULL}
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=515&LinkId=20476
- Update profile 'Mail Profile For SQL Server Agent' (Success)
- Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
Server Agent' with priority '1' (Error)
Messages
â?¢ Unable to add account SQL Agent SMTP Account to profile Mail Profile For
SQL Server Agent.
--
ADDITIONAL INFORMATION:
Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQL
Server Agent'. (Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Add+MailAccount+to+MailProfile+MailProfile&LinkId=20476
--
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
--
account name is not valid (Microsoft SQL Server, Error: 14607)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=14607&LinkId=20476Wild guess: What does below return:
SELECT @.@.SERVERNAME
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Buehler" <Buehler@.discussions.microsoft.com> wrote in message
news:39B595AE-DC22-4D4C-8921-EB67AAFD5B72@.microsoft.com...
> Configuring...
> - Create new account 'SQL Agent SMTP Account' for SMTP server {exchange
> server}(Error)
> Messages
> â?¢ Unable to create new account SQL Agent SMTP Account for SMTP server
> Microsoft.SqlServer.Management.SqlManagerUI.SQLiMailServer.
> --
> ADDITIONAL INFORMATION:
> Create failed for MailAccount 'SQL Agent SMTP Account'.
> (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+MailAccount&LinkId=20476
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> Cannot insert the value NULL into column 'servername', table
> 'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
> The statement has been terminated. (Microsoft SQL Server, Error: 515) {this
> was filled in. Don't kow why it is saying it was NULL}
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=515&LinkId=20476
>
> - Update profile 'Mail Profile For SQL Server Agent' (Success)
> - Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
> Server Agent' with priority '1' (Error)
> Messages
> â?¢ Unable to add account SQL Agent SMTP Account to profile Mail Profile For
> SQL Server Agent.
> --
> ADDITIONAL INFORMATION:
> Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQL
> Server Agent'. (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Add+MailAccount+to+MailProfile+MailProfile&LinkId=20476
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> account name is not valid (Microsoft SQL Server, Error: 14607)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=14607&LinkId=20476
>|||found solution. There is a 'bug' in the wizard. used
dbo.sysmail_add_account_sp to add account.

Error adding an Account to a Profile for 'Database Mail'

Configuring...
- Create new account 'SQL Agent SMTP Account' for SMTP server {exchange
server}(Error)
Messages
? Unable to create new account SQL Agent SMTP Account for SMTP server
Microsoft.SqlServer.Management.SqlManagerUI.SQLiMailServer.
ADDITIONAL INFORMATION:
Create failed for MailAccount 'SQL Agent SMTP Account'.
(Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?Prod...nt&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
Cannot insert the value NULL into column 'servername', table
'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
The statement has been terminated. (Microsoft SQL Server, Error: 515) {
this
was filled in. Don't kow why it is saying it was NULL}
For help, click:
http://go.microsoft.com/fwlink?Prod...15&LinkId=20476
- Update profile 'Mail Profile For SQL Server Agent' (Success)
- Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
Server Agent' with priority '1' (Error)
Messages
? Unable to add account SQL Agent SMTP Account to profile Mail Profile For
SQL Server Agent.
ADDITIONAL INFORMATION:
Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQL
Server Agent'. (Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?Prod...le&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
account name is not valid (Microsoft SQL Server, Error: 14607)
For help, click:
http://go.microsoft.com/fwlink?Prod...07&LinkId=20476Wild guess: What does below return:
SELECT @.@.SERVERNAME
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Buehler" <Buehler@.discussions.microsoft.com> wrote in message
news:39B595AE-DC22-4D4C-8921-EB67AAFD5B72@.microsoft.com...
> Configuring...
> - Create new account 'SQL Agent SMTP Account' for SMTP server {exchan
ge
> server}(Error)
> Messages
> ? Unable to create new account SQL Agent SMTP Account for SMTP server
> Microsoft.SqlServer.Management.SqlManagerUI.SQLiMailServer.
> --
> ADDITIONAL INFORMATION:
> Create failed for MailAccount 'SQL Agent SMTP Account'.
> (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...nt&LinkId=20476
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> Cannot insert the value NULL into column 'servername', table
> 'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
> The statement has been terminated. (Microsoft SQL Server, Error: 515)
3;this
> was filled in. Don't kow why it is saying it was NULL}
> For help, click:
> http://go.microsoft.com/fwlink?Prod...15&LinkId=20476
>
> - Update profile 'Mail Profile For SQL Server Agent' (Success)
> - Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
> Server Agent' with priority '1' (Error)
> Messages
> ? Unable to add account SQL Agent SMTP Account to profile Mail Profile F
or
> SQL Server Agent.
> --
> ADDITIONAL INFORMATION:
> Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQ
L
> Server Agent'. (Microsoft.SqlServer.Smo)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...le&LinkId=20476
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> account name is not valid (Microsoft SQL Server, Error: 14607)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...07&LinkId=20476
>|||found solution. There is a 'bug' in the wizard. used
dbo.sysmail_add_account_sp to add account.

Error adding an Account to a Profile for 'Database Mail'

Configuring...
- Create new account 'SQL Agent SMTP Account' for SMTP server {exchange
server}(Error)
Messages
?Unable to create new account SQL Agent SMTP Account for SMTP server
Microsoft.SqlServer.Management.SqlManagerUI.SQLiMa ilServer.
ADDITIONAL INFORMATION:
Create failed for MailAccount 'SQL Agent SMTP Account'.
(Microsoft.SqlServer.Smo)
For help, click:
[url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00. 3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo. ExceptionTemplates.FailedOperationExceptionText&Ev tID=Create+MailAccount&LinkId=20476[/url]
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
Cannot insert the value NULL into column 'servername', table
'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
The statement has been terminated. (Microsoft SQL Server, Error: 515) {this
was filled in. Don't kow why it is saying it was NULL}
For help, click:
[url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .1399&EvtSrc=MSSQLServer&EvtID=515&LinkId=20476[/url]
- Update profile 'Mail Profile For SQL Server Agent' (Success)
- Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
Server Agent' with priority '1' (Error)
Messages
?Unable to add account SQL Agent SMTP Account to profile Mail Profile For
SQL Server Agent.
ADDITIONAL INFORMATION:
Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQL
Server Agent'. (Microsoft.SqlServer.Smo)
For help, click:
[url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00. 3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo. ExceptionTemplates.FailedOperationExceptionText&Ev tID=Add+MailAccount+to+MailProfile+MailProfile&Lin kId=20476[/url]
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
account name is not valid (Microsoft SQL Server, Error: 14607)
For help, click:
[url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .1399&EvtSrc=MSSQLServer&EvtID=14607&LinkId=20476[ /url]
Wild guess: What does below return:
SELECT @.@.SERVERNAME
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Buehler" <Buehler@.discussions.microsoft.com> wrote in message
news:39B595AE-DC22-4D4C-8921-EB67AAFD5B72@.microsoft.com...
> Configuring...
> - Create new account 'SQL Agent SMTP Account' for SMTP server {exchange
> server}(Error)
> Messages
> ? Unable to create new account SQL Agent SMTP Account for SMTP server
> Microsoft.SqlServer.Management.SqlManagerUI.SQLiMa ilServer.
> --
> ADDITIONAL INFORMATION:
> Create failed for MailAccount 'SQL Agent SMTP Account'.
> (Microsoft.SqlServer.Smo)
> For help, click:
> [url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00. 3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo. ExceptionTemplates.FailedOperationExceptionText&Ev tID=Create+MailAccount&LinkId=20476[/url]
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> Cannot insert the value NULL into column 'servername', table
> 'msdb.dbo.sysmail_server'; column does not allow nulls. INSERT fails.
> The statement has been terminated. (Microsoft SQL Server, Error: 515) {this
> was filled in. Don't kow why it is saying it was NULL}
> For help, click:
> [url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .1399&EvtSrc=MSSQLServer&EvtID=515&LinkId=20476[/url]
>
> - Update profile 'Mail Profile For SQL Server Agent' (Success)
> - Add account 'SQL Agent SMTP Account' to profile 'Mail Profile For SQL
> Server Agent' with priority '1' (Error)
> Messages
> ? Unable to add account SQL Agent SMTP Account to profile Mail Profile For
> SQL Server Agent.
> --
> ADDITIONAL INFORMATION:
> Add MailAccount to MailProfile failed for MailProfile 'Mail Profile For SQL
> Server Agent'. (Microsoft.SqlServer.Smo)
> For help, click:
> [url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00. 3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo. ExceptionTemplates.FailedOperationExceptionText&Ev tID=Add+MailAccount+to+MailProfile+MailProfile&Lin kId=20476[/url]
> --
> An exception occurred while executing a Transact-SQL statement or batch.
> (Microsoft.SqlServer.ConnectionInfo)
> --
> account name is not valid (Microsoft SQL Server, Error: 14607)
> For help, click:
> [url]http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00 .1399&EvtSrc=MSSQLServer&EvtID=14607&LinkId=20476[ /url]
>
|||found solution. There is a 'bug' in the wizard. used
dbo.sysmail_add_account_sp to add account.

Error adding a new job

I'm creating a new job and getting a failure when applying it to the server. When I script it is seems to work fine via SQL management studio. I haven't added any steps or a schedule yet, could this be the cause of the error the errors are a bit nebulous to say the least (hopefully the sql server errors will get passed through in next service pack)! Anyway heres the code, its a mixture of smo and my apps code:

//refresh jobs from server, releasing objects..

this.JobServer().Jobs.Refresh(true);

//create new job

m_oJob = new Agent.Job();

//loop through checking name (non case specific)

while(bExists==true)

{

n++;

bExists = false;

foreach(Agent.Job oJob in this.JobServer().Jobs)

{

if (oJob.Name.ToLower()==string.Format("[{0}] {1}",strName.ToLower() ,n.ToString()).ToLower() )

bExists = true;

}

}

m_oJob.Parent = this.JobServer();

//set name

m_oJob.Name = string.Format("[{0}] {1}",strName,n.ToString());

m_oJob.Description = String.Format ("Schedule for analytics job {0}",m_oScheduleJob.Name);

//set job owner to login

m_oJob.OwnerLoginName = m_oScheduleJob.Owner;

m_oJob.IsEnabled = true;

m_oJob.StartStepID = 1;

m_oJob.EventLogLevel = Microsoft.SqlServer.Management.Smo.Agent.CompletionAction.OnFailure;

m_oJob.EmailLevel = Microsoft.SqlServer.Management.Smo.Agent.CompletionAction.Never;

m_oJob.NetSendLevel = Microsoft.SqlServer.Management.Smo.Agent.CompletionAction.Never;

m_oJob.PageLevel = Microsoft.SqlServer.Management.Smo.Agent.CompletionAction.Never;

m_oJob.OperatorToEmail = "";

m_oJob.OperatorToNetSend = "";

m_oJob.OperatorToPage = "";

m_oJob.DeleteLevel = Microsoft.SqlServer.Management.Smo.Agent.CompletionAction.Never;

if (!((Agent.JobServer)this.JobServer()).JobCategories.Contains("Analytics Job"))

{

Agent.JobCategory c = new Agent.JobCategory(this.JobServer(), "Analytics Job");

c.Create();

}

m_oJob.Category = "Analytics Job";

//assign to server

m_oJob.ApplyToTargetServer("myserver"); --> fails

m_oJob.ApplyToTargetServer("(local)"); --> fails

m_oJob.ApplyToTargetServer("myserver.dnssuffix"); --> fails

Ok figured out that you need to call the create before targeting server (should have looked at previous posts more closely, informative errors would have been good though - resorting to scripting and checking errors from sql for clues). Once saved need to call alter to change the objects however calling targetserver twice triggers an error anyone know how I can tell if its been called already?

|||I'm shooting from the hip here, so I will taking a closer look if I have a little more time, but I think that Job.EnumTargetServers() will do the trick. Let me know if that worked...|||Yes thats correct, thanks.