From jwcolby at colbyconsulting.com Sun Apr 1 07:13:16 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Sun, 1 Apr 2007 08:13:16 -0400
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
Message-ID: <002701c77457$23ef98b0$657aa8c0@m6805>
In an Access database the PKID (autonumber) of a table is available the
instant after doing the insert or AddNew, so I would use code such as:
With RS
.Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
'build a logout record.
.AddNew
!LWSL_IDLWSU = mlngUserID
!LWSL_FE = CurrentProject.name
!LWSL_Login = blnLogIn
!LWSL_WorkstationID = CurrentMachineName()
mlngLogID = !LWSL_ID
.Update
.Close
End With
the code line
mlngLogID = !LWSL_ID
fails when used in SQL Server because the ID is not yet valid. How do I
work around this when the table is out in SQL Server?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From accessd at shaw.ca Sun Apr 1 07:58:04 2007
From: accessd at shaw.ca (Jim Lawrence)
Date: Sun, 01 Apr 2007 05:58:04 -0700
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In-Reply-To: <002701c77457$23ef98b0$657aa8c0@m6805>
Message-ID: <0JFT002QUL694X15@l-daemon>
Hi John:
Check these scripts out:
SELECT @@IDENTITY
This is everyone's favorite function, unchanged from earlier versions of SQL
Server. It returns the last IDENTITY value produced on a connection,
regardless of the table that produced the value, and regardless of the scope
of the statement that produced the value.
SELECT IDENT_CURRENT('tablename')
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.
SELECT SCOPE_IDENTITY()
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.
HTH
Jim
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Sunday, April 01, 2007 5:13 AM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In an Access database the PKID (autonumber) of a table is available the
instant after doing the insert or AddNew, so I would use code such as:
With RS
.Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
'build a logout record.
.AddNew
!LWSL_IDLWSU = mlngUserID
!LWSL_FE = CurrentProject.name
!LWSL_Login = blnLogIn
!LWSL_WorkstationID = CurrentMachineName()
mlngLogID = !LWSL_ID
.Update
.Close
End With
the code line
mlngLogID = !LWSL_ID
fails when used in SQL Server because the ID is not yet valid. How do I
work around this when the table is out in SQL Server?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From fhtapia at gmail.com Sun Apr 1 12:05:32 2007
From: fhtapia at gmail.com (Francisco Tapia)
Date: Sun, 1 Apr 2007 10:05:32 -0700
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In-Reply-To: <0JFT002QUL694X15@l-daemon>
References: <002701c77457$23ef98b0$657aa8c0@m6805> <0JFT002QUL694X15@l-daemon>
Message-ID:
you always want to use scope_identity(), because you never know if you
will introduce code in the future that may write at the same time when
your code is executing, thus providing you w/ a false @@identity
I also would avoid your coding from the client end to add the record,
instead I'd setup parameters and pass them to a sproc (stored
procedure) and allow the sproc to return a value (scope_identity())
On 4/1/07, Jim Lawrence wrote:
> Hi John:
>
> Check these scripts out:
>
>
> SELECT @@IDENTITY
> This is everyone's favorite function, unchanged from earlier versions of SQL
> Server. It returns the last IDENTITY value produced on a connection,
> regardless of the table that produced the value, and regardless of the scope
> of the statement that produced the value.
>
> SELECT IDENT_CURRENT('tablename')
> This new function returns the last IDENTITY value produced in a table,
> regardless of the connection that created the value, and regardless of the
> scope of the statement that produced the value.
>
> SELECT SCOPE_IDENTITY()
> This new function returns the last IDENTITY value produced on a connection
> and by a statement in the same scope, regardless of the table that produced
> the value.
>
>
> HTH
> Jim
>
> -----Original Message-----
> From: dba-sqlserver-bounces at databaseadvisors.com
> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
> Sent: Sunday, April 01, 2007 5:13 AM
> To: 'Access Developers discussion and problem solving';
> dba-sqlserver at databaseadvisors.com
> Subject: [dba-SQLServer] Getting the PK of a SQL Server table
>
> In an Access database the PKID (autonumber) of a table is available the
> instant after doing the insert or AddNew, so I would use code such as:
>
> With RS
> .Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
> 'build a logout record.
> .AddNew
> !LWSL_IDLWSU = mlngUserID
> !LWSL_FE = CurrentProject.name
> !LWSL_Login = blnLogIn
> !LWSL_WorkstationID = CurrentMachineName()
> mlngLogID = !LWSL_ID
> .Update
> .Close
> End With
>
> the code line
>
> mlngLogID = !LWSL_ID
>
> fails when used in SQL Server because the ID is not yet valid. How do I
> work around this when the table is out in SQL Server?
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
--
-Francisco
http://sqlthis.blogspot.com | Tsql and More...
From jwcolby at colbyconsulting.com Sun Apr 1 12:09:38 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Sun, 1 Apr 2007 13:09:38 -0400
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In-Reply-To: <0JFT002QUL694X15@l-daemon>
References: <002701c77457$23ef98b0$657aa8c0@m6805> <0JFT002QUL694X15@l-daemon>
Message-ID: <003b01c77480$8aea3830$657aa8c0@m6805>
Well, I can see that the first is not what I want. It would seem, in a
multi-user environment that the second is also not what I want. The third I
am incapable of understanding well enough to evaluate it. What exactly does
scope mean in this context? If I use the last method, then I change my code
as follows? Scope_Identity() sounds suspiciously like a SQL Server
function, remember that this is VBA code running in my FE. Is VBA going to
understand a SQL statement "SELECT SCOPE_Identity()" or anything remotely
like it?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim
Lawrence
Sent: Sunday, April 01, 2007 8:58 AM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Getting the PK of a SQL Server table
Hi John:
Check these scripts out:
SELECT @@IDENTITY
This is everyone's favorite function, unchanged from earlier versions of SQL
Server. It returns the last IDENTITY value produced on a connection,
regardless of the table that produced the value, and regardless of the scope
of the statement that produced the value.
SELECT IDENT_CURRENT('tablename')
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.
SELECT SCOPE_IDENTITY()
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.
HTH
Jim
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Sunday, April 01, 2007 5:13 AM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In an Access database the PKID (autonumber) of a table is available the
instant after doing the insert or AddNew, so I would use code such as:
With RS
.Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
'build a logout record.
.AddNew
!LWSL_IDLWSU = mlngUserID
!LWSL_FE = CurrentProject.name
!LWSL_Login = blnLogIn
!LWSL_WorkstationID = CurrentMachineName()
mlngLogID = !LWSL_ID
.Update
.Close
End With
the code line
mlngLogID = !LWSL_ID
fails when used in SQL Server because the ID is not yet valid. How do I
work around this when the table is out in SQL Server?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From jwcolby at colbyconsulting.com Sun Apr 1 12:24:42 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Sun, 1 Apr 2007 13:24:42 -0400
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In-Reply-To:
References: <002701c77457$23ef98b0$657aa8c0@m6805> <0JFT002QUL694X15@l-daemon>
Message-ID: <003d01c77482$a4f09830$657aa8c0@m6805>
Francisco,
>I also would avoid your coding from the client end to add the record,
instead I'd setup parameters and pass them to a sproc (stored
procedure) and allow the sproc to return a value (scope_identity())
Of course that is true. Unfortunately my client is now entering the third
week of the database corrupting 6 times per day. I am doing an emergency
port to SQL Server to get THAT problem stabilized. I just want my
APPLICATION to run, tweaks can follow. For now, I have the code shown below
and need to change it, 'cause it don't work no more.
Dim RS As ADODB.Recordset
If mlngUserID = 0 Then Exit Function
Set RS = New ADODB.Recordset
With RS
.Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
'build a logout record.
.AddNew
!LWSL_IDLWSU = mlngUserID
!LWSL_FE = CurrentProject.name
!LWSL_Login = blnLogIn
!LWSL_WorkstationID = CurrentMachineName()
mlngLogID = !LWSL_ID
.Update
.Close
End With
Set RS = Nothing
The code
mlngLogID = !LWSL_ID
Fails because mlngLogID is a long int which cannot contain a null, and
!LWSL_ID returns a null. Thus I need an emergency fix that gives me back my
new ID.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco
Tapia
Sent: Sunday, April 01, 2007 1:06 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Getting the PK of a SQL Server table
you always want to use scope_identity(), because you never know if you will
introduce code in the future that may write at the same time when your code
is executing, thus providing you w/ a false @@identity
I also would avoid your coding from the client end to add the record,
instead I'd setup parameters and pass them to a sproc (stored
procedure) and allow the sproc to return a value (scope_identity())
From jwcolby at colbyconsulting.com Mon Apr 2 06:31:59 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Mon, 2 Apr 2007 07:31:59 -0400
Subject: [dba-SQLServer] Users in SQL Server
Message-ID: <000901c7751a$872c5ee0$657aa8c0@m6805>
Is there something that can be read from SQL Server to discover the count of
and even a list of users logged in to a SQL Server database? I am moving a
client from an MDB data store to SQL Server and need to get this information
on demand, using VBA.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From mikedorism at verizon.net Mon Apr 2 08:30:48 2007
From: mikedorism at verizon.net (Doris Manning)
Date: Mon, 02 Apr 2007 09:30:48 -0400
Subject: [dba-SQLServer] Users in SQL Server
In-Reply-To: <000901c7751a$872c5ee0$657aa8c0@m6805>
References: <000901c7751a$872c5ee0$657aa8c0@m6805>
Message-ID: <000601c7752b$2100c2d0$2f01a8c0@Kermit>
Yes, there is. If you are using SQL Server 2000:
1. Expand "Management"
2. Expand "Current Activity"
3. Click on "Process Info"
Doris Manning
Database Administrator
Hargrove Inc.
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Monday, April 02, 2007 7:32 AM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Users in SQL Server
Is there something that can be read from SQL Server to discover the count of
and even a list of users logged in to a SQL Server database? I am moving a
client from an MDB data store to SQL Server and need to get this information
on demand, using VBA.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From James at fcidms.com Mon Apr 2 10:02:55 2007
From: James at fcidms.com (James Barash)
Date: Mon, 2 Apr 2007 11:02:55 -0400
Subject: [dba-SQLServer] Users in SQL Server
In-Reply-To: <000901c7751a$872c5ee0$657aa8c0@m6805>
Message-ID: <00c601c77537$fef4dde0$800101df@fci.local>
John:
You can use something like:
Select loginame, hostname
>From master..sysprocesses
Where DB_NAME(dbid)='YourDatabase'
This assumes your login has permission to read from the master database.
James Barash
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Monday, April 02, 2007 7:32 AM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Users in SQL Server
Is there something that can be read from SQL Server to discover the count of
and even a list of users logged in to a SQL Server database? I am moving a
client from an MDB data store to SQL Server and need to get this information
on demand, using VBA.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From rl_stewart at highstream.net Mon Apr 2 12:50:06 2007
From: rl_stewart at highstream.net (Robert L. Stewart)
Date: Mon, 02 Apr 2007 12:50:06 -0500
Subject: [dba-SQLServer] Getting the PK of a SQL Server table
In-Reply-To:
References:
Message-ID: <200704021755.l32HtPU16837@databaseadvisors.com>
John,
You are going to have to force the save on the Access side
of the parent record and then the field on the form should
be populated.
Robert
At 12:00 PM 4/2/2007, you wrote:
>Date: Sun, 1 Apr 2007 13:24:42 -0400
>From: "JWColby"
>Subject: Re: [dba-SQLServer] Getting the PK of a SQL Server table
>To:
>Message-ID: <003d01c77482$a4f09830$657aa8c0 at m6805>
>Content-Type: text/plain; charset="us-ascii"
>
>Francisco,
>
> >I also would avoid your coding from the client end to add the record,
>instead I'd setup parameters and pass them to a sproc (stored
>procedure) and allow the sproc to return a value (scope_identity())
>
>Of course that is true. Unfortunately my client is now entering the third
>week of the database corrupting 6 times per day. I am doing an emergency
>port to SQL Server to get THAT problem stabilized. I just want my
>APPLICATION to run, tweaks can follow. For now, I have the code shown below
>and need to change it, 'cause it don't work no more.
>
>Dim RS As ADODB.Recordset
> If mlngUserID = 0 Then Exit Function
> Set RS = New ADODB.Recordset
> With RS
> .Open "usystbllwsLog", gcnn, adOpenKeyset, adLockPessimistic
> 'build a logout record.
> .AddNew
> !LWSL_IDLWSU = mlngUserID
> !LWSL_FE = CurrentProject.name
> !LWSL_Login = blnLogIn
> !LWSL_WorkstationID = CurrentMachineName()
> mlngLogID = !LWSL_ID
> .Update
> .Close
> End With
> Set RS = Nothing
>
>The code
>
> mlngLogID = !LWSL_ID
>
>Fails because mlngLogID is a long int which cannot contain a null, and
>!LWSL_ID returns a null. Thus I need an emergency fix that gives me back my
>new ID.
>
>John W. Colby
>Colby Consulting
>www.ColbyConsulting.com
From jlawrenc1 at shaw.ca Thu Apr 5 12:18:23 2007
From: jlawrenc1 at shaw.ca (Jim Lawrence)
Date: Thu, 05 Apr 2007 10:18:23 -0700
Subject: [dba-SQLServer] A new implementation of the MS SQL DB
In-Reply-To: <200704021755.l32HtPU16837@databaseadvisors.com>
Message-ID: <0JG100KV5BVMKN50@l-daemon>
Hi All:
There seems to be an interesting design for MS SQL Database. For those who
have used classes here is a new implementation:
http://msdn2.microsoft.com/en-us/library/bb245675.aspx
http://www.sqlserverbible.com/ordbms.htm
Jim
From jwcolby at colbyconsulting.com Thu Apr 5 23:14:20 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Fri, 6 Apr 2007 00:14:20 -0400
Subject: [dba-SQLServer] Recover SQL Server
Message-ID: <000901c77802$0d82c490$657aa8c0@m6805>
Is it possible to recover a set of SQL Server databases that were mounted
(active) when my computer died? I have the database files themselves out on
a data drive, and I have the SQL Server directory and all of its sub
directories out on the same drive, but the system that ran that sql server
is unrecoverable. And of course I do not have a recent backup.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From jlawrenc1 at shaw.ca Fri Apr 6 05:55:40 2007
From: jlawrenc1 at shaw.ca (Jim Lawrence)
Date: Fri, 06 Apr 2007 03:55:40 -0700
Subject: [dba-SQLServer] Recover SQL Server
In-Reply-To: <000901c77802$0d82c490$657aa8c0@m6805>
Message-ID: <0JG200IN6OTO76N0@l-daemon>
Hi John:
Maybe I am missing the question but as long as you have physical access to a
databases' mdf and ldf files you can just re-attach them.
Jim
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Thursday, April 05, 2007 9:14 PM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Recover SQL Server
Is it possible to recover a set of SQL Server databases that were mounted
(active) when my computer died? I have the database files themselves out on
a data drive, and I have the SQL Server directory and all of its sub
directories out on the same drive, but the system that ran that sql server
is unrecoverable. And of course I do not have a recent backup.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From listmaster at databaseadvisors.com Fri Apr 6 08:40:34 2007
From: listmaster at databaseadvisors.com (Bryan Carbonnell)
Date: Fri, 06 Apr 2007 09:40:34 -0400
Subject: [dba-SQLServer] Administrivia - Server Upgrades
Message-ID: <46161592.19068.306522A@listmaster.databaseadvisors.com>
Hello all,
I hope you are all having a good Easter Weekend and that you won't
miss the lists too much.
I have to do an upgrade on the server, so it will be mostly up, but
at some points going down over this weekend.
If, at the end of the day, you are having problems, please e-mail me
at listmaster at databaseadvisors.com or IF THAT DOES NOT WORK, e-mail
me at bryan at carbonnell.ca
The main reason for this upgrade is for spam control. We are getting
hammered at the server and I need to implement a spam control
solution.
Again, if you have any problems, contact me at
listmaster at databaseadvisors.com or bryan at carbonnell.ca
--
Bryan Carbonnell - listmaster at databaseadvisors.com
From listmaster at databaseadvisors.com Fri Apr 6 19:17:16 2007
From: listmaster at databaseadvisors.com (Bryan Carbonnell)
Date: Fri, 06 Apr 2007 20:17:16 -0400
Subject: [dba-SQLServer] Administrivia - Server Upgrade Complete
Message-ID: <4616AACC.16681.54D3C94@listmaster.databaseadvisors.com>
Well, the server upgrade has been completed.
Hopefully you didn't notice too much of a disruption through out the
day today.
If you run across anything out of the ordinary, please e-mail me at
listmaster at databaseadvisors.com or if that does not work,
bryan at carbonnell.ca
--
Bryan Carbonnell - listmaster at databaseadvisors.com
From fhtapia at gmail.com Wed Apr 11 23:24:58 2007
From: fhtapia at gmail.com (Francisco Tapia)
Date: Wed, 11 Apr 2007 21:24:58 -0700
Subject: [dba-SQLServer] Restoring a master db
Message-ID:
Today I had a server go down, and my sysadmin had to rebuild the OS.
After re-installing SS2k SP4, I went ahead and placed the server in
single user mode and restored the original master db, and also went
ahead and restored the msdb (for scheduling task I had). One thing
that did not go smoothly was the userid's that were restored via
Master db restore. i've had to re-create the windows users and simply
re-type the Sql users. I don't know why this happend, it almost was
as if the users were orphaned.
I'm posting here in case others have ran into this problem... I was
quite at a loss since I didn't quite know what to even google for...
the closest match was when you migrate users. and the point I guess is
that I wasn't they were already on the same server (master db).
any ideas?
:) thanks,
--
-Francisco
http://sqlthis.blogspot.com | Tsql and More...
From fuller.artful at gmail.com Thu Apr 12 10:55:32 2007
From: fuller.artful at gmail.com (Arthur Fuller)
Date: Thu, 12 Apr 2007 11:55:32 -0400
Subject: [dba-SQLServer] Restoring a master db
In-Reply-To:
References:
Message-ID: <29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
This is a bit after the fact, I realize, but I have a script that will write
a script for you that records all the user info (logins, users, passwords,
etc.) so you can just run the script in future to avoid all the hand-work. I
don't have it with me at the moment, but I'll send it off-list if you like.
Arthur
On 4/12/07, Francisco Tapia wrote:
>
> Today I had a server go down, and my sysadmin had to rebuild the OS.
> After re-installing SS2k SP4, I went ahead and placed the server in
> single user mode and restored the original master db, and also went
> ahead and restored the msdb (for scheduling task I had). One thing
> that did not go smoothly was the userid's that were restored via
> Master db restore. i've had to re-create the windows users and simply
> re-type the Sql users. I don't know why this happend, it almost was
> as if the users were orphaned.
>
> I'm posting here in case others have ran into this problem... I was
> quite at a loss since I didn't quite know what to even google for...
> the closest match was when you migrate users. and the point I guess is
> that I wasn't they were already on the same server (master db).
>
> any ideas?
>
> :) thanks,
>
> --
> -Francisco
> http://sqlthis.blogspot.com | Tsql and More...
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
From jwcolby at colbyconsulting.com Thu Apr 12 11:03:10 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Thu, 12 Apr 2007 12:03:10 -0400
Subject: [dba-SQLServer] Restoring a master db
In-Reply-To: <29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
References:
<29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
Message-ID: <009a01c77d1c$11e97fa0$657aa8c0@m6805>
Arthur,
That would make a great addition to the DatabaseAdvisors "handy dandy code"
pages.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Thursday, April 12, 2007 11:56 AM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Restoring a master db
This is a bit after the fact, I realize, but I have a script that will write
a script for you that records all the user info (logins, users, passwords,
etc.) so you can just run the script in future to avoid all the hand-work. I
don't have it with me at the moment, but I'll send it off-list if you like.
Arthur
On 4/12/07, Francisco Tapia wrote:
>
> Today I had a server go down, and my sysadmin had to rebuild the OS.
> After re-installing SS2k SP4, I went ahead and placed the server in
> single user mode and restored the original master db, and also went
> ahead and restored the msdb (for scheduling task I had). One thing
> that did not go smoothly was the userid's that were restored via
> Master db restore. i've had to re-create the windows users and simply
> re-type the Sql users. I don't know why this happend, it almost was
> as if the users were orphaned.
>
> I'm posting here in case others have ran into this problem... I was
> quite at a loss since I didn't quite know what to even google for...
> the closest match was when you migrate users. and the point I guess is
> that I wasn't they were already on the same server (master db).
>
> any ideas?
>
> :) thanks,
>
> --
> -Francisco
> http://sqlthis.blogspot.com | Tsql and More...
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From fuller.artful at gmail.com Thu Apr 12 11:41:15 2007
From: fuller.artful at gmail.com (Arthur Fuller)
Date: Thu, 12 Apr 2007 12:41:15 -0400
Subject: [dba-SQLServer] Restoring a master db
In-Reply-To: <009a01c77d1c$11e97fa0$657aa8c0@m6805>
References:
<29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
<009a01c77d1c$11e97fa0$657aa8c0@m6805>
Message-ID: <29f585dd0704120941j5aa7efft1c4acb3a7f09fb40@mail.gmail.com>
Good idea. You shall have it when I get home.
Arthur
On 4/12/07, JWColby wrote:
>
> Arthur,
>
> That would make a great addition to the DatabaseAdvisors "handy dandy
> code"
> pages.
>
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> -----Original Message-----
> From: dba-sqlserver-bounces at databaseadvisors.com
> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
> Fuller
> Sent: Thursday, April 12, 2007 11:56 AM
> To: dba-sqlserver at databaseadvisors.com
> Subject: Re: [dba-SQLServer] Restoring a master db
>
> This is a bit after the fact, I realize, but I have a script that will
> write
> a script for you that records all the user info (logins, users, passwords,
> etc.) so you can just run the script in future to avoid all the hand-work.
> I
> don't have it with me at the moment, but I'll send it off-list if you
> like.
>
> Arthur
>
>
From fhtapia at gmail.com Thu Apr 12 12:02:46 2007
From: fhtapia at gmail.com (Francisco Tapia)
Date: Thu, 12 Apr 2007 10:02:46 -0700
Subject: [dba-SQLServer] Restoring a master db
In-Reply-To: <29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
References:
<29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
Message-ID:
Arthur is this the revlogin script?
http://support.microsoft.com/default.aspx?scid=kb;en-us;246133
The issue is that the server was down, and we couldn't load it at
all... my sysadmin ended up redoing the entire system. I restored the
masterdb, but it may be a problem that the hashes that are saved in
the sysuser table do not match the sid key from the OS since it was
re-installed.
--
Francisco
On 4/12/07, Arthur Fuller wrote:
> This is a bit after the fact, I realize, but I have a script that will write
> a script for you that records all the user info (logins, users, passwords,
> etc.) so you can just run the script in future to avoid all the hand-work. I
> don't have it with me at the moment, but I'll send it off-list if you like.
>
> Arthur
>
>
> On 4/12/07, Francisco Tapia wrote:
> >
> > Today I had a server go down, and my sysadmin had to rebuild the OS.
> > After re-installing SS2k SP4, I went ahead and placed the server in
> > single user mode and restored the original master db, and also went
> > ahead and restored the msdb (for scheduling task I had). One thing
> > that did not go smoothly was the userid's that were restored via
> > Master db restore. i've had to re-create the windows users and simply
> > re-type the Sql users. I don't know why this happend, it almost was
> > as if the users were orphaned.
> >
> > I'm posting here in case others have ran into this problem... I was
> > quite at a loss since I didn't quite know what to even google for...
> > the closest match was when you migrate users. and the point I guess is
> > that I wasn't they were already on the same server (master db).
> >
> > any ideas?
> >
> > :) thanks,
> >
> > --
> > -Francisco
> > http://sqlthis.blogspot.com | Tsql and More...
> > _______________________________________________
> > dba-SQLServer mailing list
> > dba-SQLServer at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> > http://www.databaseadvisors.com
> >
> >
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
--
-Francisco
http://sqlthis.blogspot.com | Tsql and More...
From fuller.artful at gmail.com Thu Apr 12 13:08:31 2007
From: fuller.artful at gmail.com (Arthur Fuller)
Date: Thu, 12 Apr 2007 14:08:31 -0400
Subject: [dba-SQLServer] Restoring a master db
In-Reply-To:
References:
<29f585dd0704120855v215fd8f6ve6c1e718df63ca78@mail.gmail.com>
Message-ID: <29f585dd0704121108q68127a67l13608ea1f2281200@mail.gmail.com>
Not identical but very close. I rolled my own. I didn't know there already
was one.
Arthur
On 4/12/07, Francisco Tapia wrote:
>
> Arthur is this the revlogin script?
>
> http://support.microsoft.com/default.aspx?scid=kb;en-us;246133
>
> The issue is that the server was down, and we couldn't load it at
> all... my sysadmin ended up redoing the entire system. I restored the
> masterdb, but it may be a problem that the hashes that are saved in
> the sysuser table do not match the sid key from the OS since it was
> re-installed.
>
> --
> Francisco
>
> On 4/12/07, Arthur Fuller wrote:
> > This is a bit after the fact, I realize, but I have a script that will
> write
> > a script for you that records all the user info (logins, users,
> passwords,
> > etc.) so you can just run the script in future to avoid all the
> hand-work. I
> > don't have it with me at the moment, but I'll send it off-list if you
> like.
> >
> > Arthur
> >
> >
> > On 4/12/07, Francisco Tapia wrote:
> > >
> > > Today I had a server go down, and my sysadmin had to rebuild the OS.
> > > After re-installing SS2k SP4, I went ahead and placed the server in
> > > single user mode and restored the original master db, and also went
> > > ahead and restored the msdb (for scheduling task I had). One thing
> > > that did not go smoothly was the userid's that were restored via
> > > Master db restore. i've had to re-create the windows users and simply
> > > re-type the Sql users. I don't know why this happend, it almost was
> > > as if the users were orphaned.
> > >
> > > I'm posting here in case others have ran into this problem... I was
> > > quite at a loss since I didn't quite know what to even google for...
> > > the closest match was when you migrate users. and the point I guess is
> > > that I wasn't they were already on the same server (master db).
> > >
> > > any ideas?
> > >
> > > :) thanks,
> > >
> > > --
> > > -Francisco
> > > http://sqlthis.blogspot.com | Tsql and More...
> > > _______________________________________________
> > > dba-SQLServer mailing list
> > > dba-SQLServer at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> > > http://www.databaseadvisors.com
> > >
> > >
> > _______________________________________________
> > dba-SQLServer mailing list
> > dba-SQLServer at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> > http://www.databaseadvisors.com
> >
> >
>
>
> --
> -Francisco
> http://sqlthis.blogspot.com | Tsql and More...
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
From jlawrenc1 at shaw.ca Fri Apr 13 09:46:56 2007
From: jlawrenc1 at shaw.ca (Jim Lawrence)
Date: Fri, 13 Apr 2007 07:46:56 -0700
Subject: [dba-SQLServer] OT Friday: Fun with MS SQL
In-Reply-To: <29f585dd0704121108q68127a67l13608ea1f2281200@mail.gmail.com>
Message-ID: <0JGF00CPFY7H83J0@l-daemon>
OT Friday:
Tired of those plain MS SQL DBs... try this:
http://msdn2.microsoft.com/en-us/library/bb245675.aspx
...and...
http://www.sqlserverbible.com/ordbms.htm
Jim
From jwcolby at colbyconsulting.com Mon Apr 16 07:56:41 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Mon, 16 Apr 2007 08:56:41 -0400
Subject: [dba-SQLServer] Allow remote connections
Message-ID: <000801c78026$ae63ff10$657aa8c0@m6805>
I am trying to connect to a SQL Server 2005 database from .NET. I have a
valid SSIS but it fails to connect. The warning says that by default SQL
Server does not allow remote connections, and I did just do a default
install. Can anyone step me through setting the property to allow remote
connections?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From mwp.reid at qub.ac.uk Mon Apr 16 08:05:20 2007
From: mwp.reid at qub.ac.uk (Martin Reid)
Date: Mon, 16 Apr 2007 14:05:20 +0100
Subject: [dba-SQLServer] Allow remote connections
References: <000801c78026$ae63ff10$657aa8c0@m6805>
Message-ID:
John
This might help
http://support.microsoft.com/kb/914277
Martin
Martin WP Reid
Training and Assessment Unit
Riddle Hall
Belfast
tel: 02890 974477
________________________________
From: dba-sqlserver-bounces at databaseadvisors.com on behalf of JWColby
Sent: Mon 16/04/2007 13:56
To: dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Allow remote connections
I am trying to connect to a SQL Server 2005 database from .NET. I have a
valid SSIS but it fails to connect. The warning says that by default SQL
Server does not allow remote connections, and I did just do a default
install. Can anyone step me through setting the property to allow remote
connections?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From jwcolby at colbyconsulting.com Thu Apr 19 05:54:25 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Thu, 19 Apr 2007 06:54:25 -0400
Subject: [dba-SQLServer] Managing orders database
Message-ID: <000001c78271$19039910$657aa8c0@m6805>
I emailed the group a few months ago about strategies for managing the
multitude of queries / views created in the process of filling count orders
for my bulk mail client. This client will send "orders" for counts of
records, perhaps something like "a count of all the addresses in the
supplied list of zips, where income = X and age between ..." etc. They then
come back for modifications to the counts - "refining" the count request.
They may come back for "refinements" a half dozen times or more. Once they
are satisfied with the counts they just "go away", i.e. all activity on that
order ceases. It is possible however that they may come back weeks or even
months later and ask for more "refinements" to the counts so it is critical
to keep the order information / views pretty much forever. This process
leaves me with, in some instances, a dozen or two views used to build up the
count requests for each order. Given that the client may do a handful of
completely different count requests (for different clients of theirs) every
week, these views can proliferate and create a maintenance nightmare.
I discussed with the group solving the problem by creating a new database
for each order. Doing so isolates all of the views required for any given
order into a database file named to match the order from my client. These
database files are quite small (about 1-2 megs). The downside is that now
the number of databases proliferates in my database directory out on disk.
I have implemented this strategy and in fact it is working quite well. I
can disconnect the database for a given order as activity for that order
ceases, thus it no longer appears in the list of databases inside of
Management studio. In the event that the client comes back to me to get new
counts for that order I can simply re-attach the database and continue
working in that order database. Since the order databases are named with
the order number from my client, it is dead simple to find and attach the
order database. Since each order database has exactly and only the views
required for processing that order, managing the views is vastly simplified.
No longer do I have hundreds of views in a single database attempting to use
a naming convention to keep them straight, and no longer do I have to wade
through views that have nothing to do with the order I am working on. I
keep the order databases attached until activity ceases, then disconnect
them.
"Works fine, lasts a long time with proper maintenance" as we used to say
somewhere in the past.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From DavidL at sierranevada.com Thu Apr 19 13:42:24 2007
From: DavidL at sierranevada.com (David Lewis)
Date: Thu, 19 Apr 2007 11:42:24 -0700
Subject: [dba-SQLServer] Managing orders database
In-Reply-To:
References:
Message-ID: <00101736F13D774F88C54058CB2663C8013E175A@celebration.sierranevada.corp>
John: Interesting way of handling it. It sounds as if all the data is
in one database, and you create new db's that are subsets of that data.
If that is the case, maybe you could have achieved your goal of easy
maintenance by creating a table structure for clients, queries, and
where clauses. You could save the where clauses in a child table, and
run them, refine (ie add a record with a new where clause), etc. That
way you would have one db with tables with the data, and a few small
tables recording the queries. Just a thought. Probably I don't have
all the details of the project, though. D
From jwcolby at colbyconsulting.com Thu Apr 19 17:22:53 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Thu, 19 Apr 2007 18:22:53 -0400
Subject: [dba-SQLServer] Managing orders database
In-Reply-To: <00101736F13D774F88C54058CB2663C8013E175A@celebration.sierranevada.corp>
References:
<00101736F13D774F88C54058CB2663C8013E175A@celebration.sierranevada.corp>
Message-ID: <001901c782d1$46790320$657aa8c0@m6805>
Long term that is actually a much better solution.
There is ATM a set of a few tables in one database. As I take orders
(counts) I build the sets of views that implement them, but the views
reference data (currently) out in another database where the actual data is
stored.
Actually it is more than a where clause though. It typically takes anywhere
from one to 4 joins, sometimes outer joins, then pulling where fields and
counts. Thus I tend to use base views and views joined to views, with those
counting and filtering. I do like the concept of storing SQL in a table,
particularly since I could then have a real order database with an order
table.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Lewis
Sent: Thursday, April 19, 2007 2:42 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Managing orders database
John: Interesting way of handling it. It sounds as if all the data is in
one database, and you create new db's that are subsets of that data.
If that is the case, maybe you could have achieved your goal of easy
maintenance by creating a table structure for clients, queries, and where
clauses. You could save the where clauses in a child table, and run them,
refine (ie add a record with a new where clause), etc. That way you would
have one db with tables with the data, and a few small tables recording the
queries. Just a thought. Probably I don't have all the details of the
project, though. D
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
From DavidL at sierranevada.com Fri Apr 20 12:14:47 2007
From: DavidL at sierranevada.com (David Lewis)
Date: Fri, 20 Apr 2007 10:14:47 -0700
Subject: [dba-SQLServer] dba-SQLServer Digest, Vol 50, Issue 10
In-Reply-To:
References:
Message-ID: <00101736F13D774F88C54058CB2663C8013E1A15@celebration.sierranevada.corp>
John: If your tables are very large, and you find that just storing sql
statements impacts performance (that is, if you run the query as
execsql, which is the least desireable from the point of view of
performance), you could do much more with this approach. For example,
the sql you store could be something like "CREATE VIEW vw..... blah blah
blah" where it appends all the portions of the statement from the
various tables, and at the end it also does things like "create
statistics.... " etc. so that the views actually run efficiently.
Anyway playing around with the concept will doubtless give you some
ideas on how to make it work for your needs. Just a thought. D
------------------------------
Message: 2
Date: Thu, 19 Apr 2007 18:22:53 -0400
From: "JWColby"
Subject: Re: [dba-SQLServer] Managing orders database
To:
Message-ID: <001901c782d1$46790320$657aa8c0 at m6805>
Content-Type: text/plain; charset="us-ascii"
Long term that is actually a much better solution.
There is ATM a set of a few tables in one database. As I take orders
(counts) I build the sets of views that implement them, but the views
reference data (currently) out in another database where the actual data
is
stored.
Actually it is more than a where clause though. It typically takes
anywhere
from one to 4 joins, sometimes outer joins, then pulling where fields
and
counts. Thus I tend to use base views and views joined to views, with
those
counting and filtering. I do like the concept of storing SQL in a
table,
particularly since I could then have a real order database with an order
table.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From jwcolby at colbyconsulting.com Fri Apr 20 14:43:26 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Fri, 20 Apr 2007 15:43:26 -0400
Subject: [dba-SQLServer] using a dtsx in .Net
Message-ID: <000a01c78384$2af74b80$657aa8c0@m6805>
Guys,
I am looking for a learning experience here. Using the import wizard in SQL
Server 2005 I created a .dtsx file, and successfully imported the first of
about 60 files using that from right inside of SQL Server's import wizard.
It asks if you want to save at the very end which I did, and which created
the aforementioned .dtsx file. Unfortunately that wizard does not allow you
to use that file for another file. Even more unfortunately, the files in
question are fixed width, and thus have no field info in the first line etc.
Thus to use the wizard, I would have to respecify the names and widths of
all 150 fields each and every time.
Therefore... I am attempting to use the dtsx file in .Net to do the import.
If I "open" that file, Visual studio is selected as the file to do the
opening, and if I do so it opens and shows me a tabbed object. The first
tab is a control flow, the next is a data flow, event handlers and package
explorer.
I can actually execute the entire thing from inside of Visual studio and
imports that first file, creates the table, with the field names and field
widths etc. Unfortunately, for some reason NVarChar was selected as the
default when I created this thing back in SQL Server. I managed to change
the table inside of SQL Server to just use VarChar. It was a few days ago
and I don't really remember how. I do remember that the wizards that allow
you to manipulate the table / field definitions very helpfully try and
change the length from whatever value you currently have back to 50 if you
change the data type from NVarChar to VarChar. Sometimes I think the world
is just one big IDIOT MASS.
Be that as it may, (back in Visual Studio) if I click on the data flow tab,
it shows the source as the original file. First task is to change that to
the name of the second file to be processed. If I click on the "source
connection flat file" object in that tab down below the main screen, there
is a connection string property which I can change to the next file name.
The next issue now is that the data conversion object is pulling data out of
an XML file which stubbornly insists that the destination data is NVarChar -
with the correct field lengths. If I open the wizard, I can indeed edit
this to change the datatype, but it insists on helpfully changing the field
length from the correct values (carefully entered already) back to the
standard 50. Sometimes I am absolutely CERTAIN that the entire world is one
big IDIOT MASS.
So here I am, trying to edit the data conversion object for 150 fields to
change from NVarChar to VarChar, where with each field change the very
helpful wizard insists on changing my field length back to 50. Sigh.
Idiots, all of them. If I can get this edit done I believe I can use this
thing to import the other 60 or so files.
So am I stuck with doing this all over again? Is there even one microscopic
particle of grey brain matter anywhere in the Microsoft campus? Is it just
me and the rest of the world WANTS their carefully entered field lengths
changed back to 50 if they need to change from NvarChar to VarChar (and if
so why)?
John W. Colby
Colby Consulting
www.ColbyConsulting.com
From jwcolby at colbyconsulting.com Sun Apr 22 22:56:21 2007
From: jwcolby at colbyconsulting.com (JWColby)
Date: Sun, 22 Apr 2007 23:56:21 -0400
Subject: [dba-SQLServer] using a saved SSIS with VB.Net
Message-ID: <000301c7855b$5c12e9d0$657aa8c0@m6805>
I saved an import spec from the import wizard in SQL Server 2005. I now
need to use that import spec in VB.Net, but I need to modify it. I need to
change the source file, make it an append instead of a make table / append,
and I need to modify the datatype from NVarchar to varchar. Of course I can
simply go back in to SQL Server and run the import wizard again, however
this is a fixed width file which means recreating all of the field name /
field width info a second time.
Is it possible to just do these mods on the existing import spec or should I
just bite the bullet and rebuild. I have ~ sixty more files to import into
the table and I really don't want to do this 60 times. The last time I did
this I actually built an Access app to create .csv files from the original
fixed width files. It seems like the long way around the barn but then
again I do not see how this wizard is really very useful in this case.
Anyone?
John W. Colby
Colby Consulting
www.ColbyConsulting.com