Showing posts with label databases. Show all posts
Showing posts with label databases. Show all posts

Wednesday, March 28, 2012

Problem Retrieving SCOPE_IDENTITY

A couple of Web applications in different SQL Server 2000 databases use SCOPE_IDENTITY to retrieve the key value of a record that was just inserted. It works--most of the time. However, from time to time the identity value is not retrieved. Evidence suggests that in these cases, a null value is being retrieved. This has forced me to come up with less-than-ideal workarounds for the missing identity value.

Does anyone have any idea why SCOPE_IDENTITY sometimes fails to retrieve the identity value and transmit it back to the Web page? Could a network issue cause the problem? Is there anything I can do other than rewrite the apps to use a different algorithm than using SCOPE_IDENTITY? Thanks.

I am not aware of any issues with SCOPE_IDENTITY(); this might be an application / connection issue and not a problem with SCOPE_IDENTITY(). I am certainly interested in the outcome of this. Can somebody please check me on this?|||

If you are using embedded SQL in your application it might be worth placing this logic into a stored procedure and calling that from your application. That should avoid any comms problems as the procedure will run or not run as a single call (and not have a problem between statements in the operation).

|||

Yes, the web app uses embedded SQL in classic ASP. The application was written in classic ASP and there has never been a good reason to rewrite it. The web app is the only application that performs DML on the table--there are no separate triggers or other ways into the table.

How could an embedded SQL statement in a single Web page cause scope problems? One Web page consulted during the research on this problem said this situation should be treated as a single scope.

I will probably try the stored procedure method. But I am curious as to why all sources practically demand that SCOPE_IDENTITY be used within a stored procedure when it is allowed to work in other situations.

Thanks for the input.

problem restoring master , model , msdb datbase

Hi ,
I am having some issues restoring the following databases
i tried to follow the steps in the articles -->
http://support.microsoft.com/kb/224071/en-us
what i have done :
- i am trying to restore all the databases back to the same location after
changing to a new disk
- Have reinstall SQL Server 2000 with SP3a and is i have copied the
PREVIOUS system db .mdf & .ldf files
Ques 1 : What are the sequence in restoring the system db files ?
Ques 2 : do i need to restore tempdb the location that i have installed is
my original location
Ques 3 : i followed the steps of moving 'model' database
SQL Server 2000 and SQL Server 2005
In SQL Server 2000 and in SQL Server 2005, system databases cannot be
detached by using the sp_detach_db stored procedure. Running the sp_detach_db
'model' statement does not work, and you receive the following error message:
Server: Msg 7940, Level 16, State 1, Line 1
System databases master, model, msdb, and tempdb cannot be detached.
To move the model database, you must start SQL Server together with trace
flag 3608 so SQL Server does not recover any database except the master
database.
Note You will not be able to access any user databases after you do this. You
must not perform any operations, other than the following steps, while you
use this trace flag. To add trace flag 3608 as a SQL Server startup parameter,
follow these steps: 1. In SQL Server Enterprise Manager, right-click the
server name, and then click Properties.
2. On the General tab, click Startup Parameters.
3. Add the following new parameter:
-T3608
If you are using SQL Server 2005, you can use SQL Server Configuration
Manager to change the startup parameters of the SQL Server service. For more
information about how to change the startup parameters, visit the following
Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/ms190737.aspx (
http://msdn2.microsoft.com/en-us/library/ms190737.aspx)
After you add trace flag 3608, follow these steps: 1. Stop and then restart
SQL Server.
2. Detach the model database by using the following commands:use master
go
sp_detach_db 'model'
go
3. Move the Model.mdf and Modellog.ldf files from the D:\Mssql7\Data folder
to the E:\Sqldata folder.
4. Reattach the model database by using the following commands:use master
go
sp_attach_db 'model','E:\Sqldata\model.mdf','E:\Sqldata\modellog.ldf'
go
at step 4 , when i try to reattach i got the following error something like
"Connection Broken" and i could not continue
i'll apprecaite someone can give me the exact steps of restoring a System DBs
tks & rdgs
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1Hi All ,
I have managed to successfully restore my System Database with extracts from
the 2 articles and hopefully it'll be useful to those who might use it.
if you use the article in whole from Microsoft , somehow it gives error after
moving the "master" db
Step 1 : Moving ?master? database
First, right-click on SQL Server in Enterprise Manager (EM) and choose
Properties. Next,
click the Startup Parameters as shown in Figure A. As you can see in Figure A,
the
following parameters appear in
-d is the fully qualified path for the master database data file.
-e is the fully qualified path for the error log file.
-l is the fully qualified path for the master database log
- Now, if you want to move your files you would remove the current entry and
recreate
your new entry with the correct path. For example, I am going to move the
Master database log to C:\test\.
- I would delete the -l [path] by highlighting the old parameter and choosing
remove
- Next, I would add the following entry, -l C:\test\mastlog.ldf and click OK
twice. Now, you will stop SQL Server and move the mastlog.ldf to its new
location.
Note: Please make sure you move the mastlog.ldf to the location you
configured in your
startup parameters. If you move it to a location that is not specified in the
startup
parameters, SQL Server WILL NOT start.
- Finally, start SQL Server
Step 2 : Moving ?tempdb? database
- login to Query Analyzer
- run the following scripts where 'E:\Sqldata\tempdb.mdf' is the path of the
data file and 'E:\Sqldata\templog.ldf' is the path of the txn log file. Note :
the files can be in different location
use master
go
Alter database tempdb modify file (name = tempdev, filename = 'E:\Sqldata\
tempdb.mdf')
go
Alter database tempdb modify file (name = templog, filename = 'E:\Sqldata\
templog.ldf')
Go
- Stop & ReStart SQL Server
The above steps(1 & 2) are taken from this link ?
http://www.databasejournal.com/features/mssql/article.php/3379901
Step 3 : Moving ?model? database
- In SQL Server Enterprise Manager, right-click the server name, and then
click Properties.
- On the General tab, click Startup Parameters.
- Add the following new parameter: -T3608
- Stop and then restart SQL Server.
- Detach the model database by using the following commands:
use master
go
sp_detach_db 'model'
go
- Move the Model.mdf and Modellog.ldf from its original location to the new
location
- Reattach the model database by using the following commands:
use master
go
sp_attach_db 'model','E:\Sqldata\model.mdf','E:\Sqldata\modellog.ldf'
go
- Remove the -T3608 trace flag from the startup parameters in SQL
Server Enterprise Manager or in SQL
Server Configuration Manager.
- Stop and then restart SQL Server. You can verify the change in file
locations by using the sp_helpfile
stored procedure. For example, use the following command:
use model
go
sp_helpfile
go
Step 4 : Moving ?msdb? database
- In SQL Server Enterprise Manager, right-click the server name, and then
click Properties.
- On the General tab, click Startup Parameters.
- Add the following new parameter: -T3608
- Stop and then restart SQL Server.
- Detach the model database by using the following commands:
use master
go
sp_detach_db 'msdb'
go
- Move the Msdbdata.mdf and msdblog.ldf from its original location to the new
location
- Reattach the model database by using the following commands:
use master
go
sp_attach_db 'msdb','d:\Sqldata\msdb.mdf','E:\Sqldata\msdblog.ldf'
go
- Remove the -T3608 trace flag from the startup parameters in SQL
Server Enterprise Manager or in SQL
Server Configuration Manager.
- Stop and then restart SQL Server. You can verify the change in file
locations by using the sp_helpfile
stored procedure. For example, use the following command:
use msdb
go
sp_helpfile
go
Note : To check if the db is correct you may use ? sp_helpdb in Query
Analyzer take note that the dbid for ?model? MUST be 3 else there could be
some error !!!
The above steps ( 3 & 4) are taken from ?
http://support.microsoft.com/default.aspx?scid=kb;en-us;224071
tks & rdgs
maxzsim wrote:
>Hi ,
> I am having some issues restoring the following databases
> i tried to follow the steps in the articles -->
>http://support.microsoft.com/kb/224071/en-us
>what i have done :
>- i am trying to restore all the databases back to the same location after
>changing to a new disk
> - Have reinstall SQL Server 2000 with SP3a and is i have copied the
>PREVIOUS system db .mdf & .ldf files
>Ques 1 : What are the sequence in restoring the system db files ?
>Ques 2 : do i need to restore tempdb the location that i have installed is
>my original location
>Ques 3 : i followed the steps of moving 'model' database
>SQL Server 2000 and SQL Server 2005
>In SQL Server 2000 and in SQL Server 2005, system databases cannot be
>detached by using the sp_detach_db stored procedure. Running the sp_detach_db
>'model' statement does not work, and you receive the following error message:
>Server: Msg 7940, Level 16, State 1, Line 1
>System databases master, model, msdb, and tempdb cannot be detached.
>To move the model database, you must start SQL Server together with trace
>flag 3608 so SQL Server does not recover any database except the master
>database.
>Note You will not be able to access any user databases after you do this. You
>must not perform any operations, other than the following steps, while you
>use this trace flag. To add trace flag 3608 as a SQL Server startup parameter,
>follow these steps: 1. In SQL Server Enterprise Manager, right-click the
>server name, and then click Properties.
>2. On the General tab, click Startup Parameters.
>3. Add the following new parameter:
>-T3608
>If you are using SQL Server 2005, you can use SQL Server Configuration
>Manager to change the startup parameters of the SQL Server service. For more
>information about how to change the startup parameters, visit the following
>Microsoft Developer Network (MSDN) Web site:
>http://msdn2.microsoft.com/en-us/library/ms190737.aspx (
>http://msdn2.microsoft.com/en-us/library/ms190737.aspx)
>After you add trace flag 3608, follow these steps: 1. Stop and then restart
>SQL Server.
>2. Detach the model database by using the following commands:use master
> go
> sp_detach_db 'model'
> go
>3. Move the Model.mdf and Modellog.ldf files from the D:\Mssql7\Data folder
>to the E:\Sqldata folder.
>4. Reattach the model database by using the following commands:use master
> go
> sp_attach_db 'model','E:\Sqldata\model.mdf','E:\Sqldata\modellog.ldf'
> go
>
>at step 4 , when i try to reattach i got the following error something like
>"Connection Broken" and i could not continue
>i'll apprecaite someone can give me the exact steps of restoring a System DBs
>tks & rdgs
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200606/1

Friday, March 23, 2012

Problem processing cubes in example Adventure Works DW

Hi,

I've installed the sample databases, and I am trying to process the cubes in the sample.

I keep getting errors like this, for cube "adventure Works":

Errors in the OLAP storage engine: The attribute key cannot be found: Table: dbo_DimCustomer, Column: AddressLine1, Value: 8011 Mcnutt Ave. Errors in the OLAP storage engine: The record was skipped because the attribute key was not found. Attribute: Customer of Dimension: Customer from Database: Adventure Works DW, Record: 1024.

I have set processing to ignore errors, but the cube is never successfully processed.

What can I do to get the cube processed?

Hi John,

Could you please check that you have installed the right AdventureWorksDW relational DB, and that your AdventureWorksDW AS DB's datasource points to it.

YL

|||

Yan,

The "Adventure Works DW" AS DB datasource points to the "AdventureWorksDW" database installed as sample (on the same machine), going by the connection string.

How can I check that I have the "right" AdventureWorksDW?

John

|||

John,

If you installed the sample Adventure Works DW successfully, and verified that the relational DB is also installed and no records in it were removed, the processing should work.

Yan

|||

I've fixed the problem. I had SS 2000 installed as my default instance and 2005 as a named instance and it appears that was the source of the problem. I've had to uninstall both, then reinstall only 2005, but the sample is now working.

Problem processing cubes in example Adventure Works DW

Hi,

I've installed the sample databases, and I am trying to process the cubes in the sample.

I keep getting errors like this, for cube "adventure Works":

Errors in the OLAP storage engine: The attribute key cannot be found: Table: dbo_DimCustomer, Column: AddressLine1, Value: 8011 Mcnutt Ave. Errors in the OLAP storage engine: The record was skipped because the attribute key was not found. Attribute: Customer of Dimension: Customer from Database: Adventure Works DW, Record: 1024.

I have set processing to ignore errors, but the cube is never successfully processed.

What can I do to get the cube processed?

Hi John,

Could you please check that you have installed the right AdventureWorksDW relational DB, and that your AdventureWorksDW AS DB's datasource points to it.

YL

|||

Yan,

The "Adventure Works DW" AS DB datasource points to the "AdventureWorksDW" database installed as sample (on the same machine), going by the connection string.

How can I check that I have the "right" AdventureWorksDW?

John

|||

John,

If you installed the sample Adventure Works DW successfully, and verified that the relational DB is also installed and no records in it were removed, the processing should work.

Yan

|||

I've fixed the problem. I had SS 2000 installed as my default instance and 2005 as a named instance and it appears that was the source of the problem. I've had to uninstall both, then reinstall only 2005, but the sample is now working.

Wednesday, March 21, 2012

Problem Opening Databases In ASP.NET

I Have A Problem With Opening A Database With "SQLOLEDB" Provider In Web Application Projects!
The Same Database Opens In Windows Application Projects But When I Try TO Open It (Manually Or During A DataAdapter.Fill Method) In Web APPS I Get An Error Message : "Login failed for user 'NT AUTHORITY\NETWORK SERVICE'."
I Use Windows NT Authentication In Connections,
I Have SQL Server 2000 Enterprise Edition (With Default Installation) , Windows .Net Server 2003 Enterprise Edition (IIS 6) , And VS.NET 2003 Enterprise Edition (.Net Framework 1.1)
Can Anyone Tell Me What's Wrong?You need to give the ASPNET user (or the user under which the worker process is running) the appropriate rights to your database.|||Thanks For Your Advice
I Solved That Problem By Adding A New User And Settting Permissions For It
By The Way , IT Came To My Mind That I Can Use ASPNET Account , But I Don't Know The Password , It Is'nt Blank And I Did'nt Set It Myself , n I Don't Know If I Change The Password Using Computer Management / Local Users , Would Be Anything Affected?
OR ASPNET Account Is Only For This Particular Use?


Note from moderator SomeNewKid:
Please refrain from capitalizing every word. Not only does it make your post hard to read,
it also means we cannot distinguish Class names and members.|||Typically, the ASPNET user has a system generated account and is local to the machine that the website is on. At work, we use a domain-level account for our web farm and that user then has rights to our app server tier for our file share for uploading/downloading files.

I was thinking of giving your ASPNET windows user rights to the database and using integrated security...

Your database user configuration is more portable and should work just as well.

Monday, March 12, 2012

Problem moving Report Server catalog to different machine

Books On Line makes breaking out the report server databases on to a separate machine from the report server itself sound very easy. I have tried it and it is but I can't get the report server to connect to the databases once they are on the other machine.

Everything was done by the book(s). We use SSRS only for intranet use so all inside firewall. The SQL Server 2005 services on both machines (including the RS Windows service) all run as the same domain administrator account, this account was used to log in to RS Config Tool and it was told to use this account under Windows Authentication to connect to the database server. The two machines are in the same domain, even on the same switch. The only difference is the one with report server on is Windows 2000 Server SP4 and the one to which the rs databases are moving is Windows Server 2003 SP1. The account mentioned above has sysadmin rights on both SQL Servers, as well as having all the RSExecRole rights as specified in BOL. And it has rights to logon as a service in group policy on both machines. Its password hasn't been changed.

The RS Config Tool completed fine and reported no errors.

But when you try to connect to the report server you get the error:

"The report server cannot open a connection to the report server database. The logon failed. (rsReportServerDatabaseLogonFailed)" The log shows that a privilege required by the client is missing but doesn't specify what! I thought this was all taken care of when the RS Config Tool told it which account to connect with.

This is driving me daft. It should be so easy!! Does anyone have any idea what might be wrong? Nothing says I need to do anything with the encryption key when I am keeping the report server itself exactly as it was and just moving the catalog - or have I missed something here?

Grateful for any ideas.

IP Logged

Try using the Configuration Utility to generate a database script and apply that script manually in SSMS. In addition, the following posts may help (http://prologika.com/CS/blogs/blog/archive/2004/08/20/161.aspx and http://prologika.com/CS/blogs/blog/archive/2006/07/18/Swapping-the-RS-Catalog.aspx).|||

I have finally fixed this problem.

The "privilege required by the client" turned out to be "Act as part of operating system" for the ASPNET user (under which the RS web service runs) on its own native machine which is Windows 2000 Server.

Since it did not require this privilege when the report server catalog was also on this machine then I can only assume it became necessary either in principle when that catalog was moved, in which case you would think Books On Line would tell you, or because they had been moved to a Windows 2003 server machine and there then appeared some obscure (to me anyway!) conflict.

I don't suppose this would be much of a fix if either of the servers involved faced the internet but they are entirely internal so I am going with it.

Monday, February 20, 2012

problem in xp_cmdshell

Hi All,
I am new in sql server. I am taking backup of databases by
using xp_cmdshell. Can any one tell where this procedure stores the
data. I am not able to find the path for this.
If you are new to SQL Server I recommend to use the Database Maintenance
Plans to do your backups instead.
You can also directly use the BACKUP DATABASE command and schedule it in a
job.
xp_cmdshell is used to execute operating system commands so you will need to
check which commands your xp_cmdshell statement is executing.
Hope this helps,
Ben Nevarez
"mohit" wrote:

> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>
|||Hi
You don't say which version of SQL Server you are using! My guess would be
SQL Express which means that you don't have SQL Agent and that is why you are
using xp_cmdshell. If you are using a different version you could use the
backup/restore wizard and save the task as a job that can be scheduled,
otherwise check out the backup command syntax in Books Online, although SQL
Express does not come with books online it can be downloaded see
http://technet.microsoft.com/en-gb/sqlserver/bb428874.aspx for SQL 2000 see
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
John
"mohit" wrote:

> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>

problem in xp_cmdshell

Hi All,
I am new in sql server. I am taking backup of databases by
using xp_cmdshell. Can any one tell where this procedure stores the
data. I am not able to find the path for this.If you are new to SQL Server I recommend to use the Database Maintenance
Plans to do your backups instead.
You can also directly use the BACKUP DATABASE command and schedule it in a
job.
xp_cmdshell is used to execute operating system commands so you will need to
check which commands your xp_cmdshell statement is executing.
Hope this helps,
Ben Nevarez
"mohit" wrote:
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>|||xp_cmdshell doesn't store any data, it only allow you to execute some command in the OS command
interpreter. It is *what you execute* which is important.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"mohit" <goenka.mohit@.gmail.com> wrote in message
news:0987f8ee-33db-459a-92d7-073a0d494efb@.t1g2000pra.googlegroups.com...
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.|||Hi
You don't say which version of SQL Server you are using! My guess would be
SQL Express which means that you don't have SQL Agent and that is why you are
using xp_cmdshell. If you are using a different version you could use the
backup/restore wizard and save the task as a job that can be scheduled,
otherwise check out the backup command syntax in Books Online, although SQL
Express does not come with books online it can be downloaded see
http://technet.microsoft.com/en-gb/sqlserver/bb428874.aspx for SQL 2000 see
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
John
"mohit" wrote:
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>