I'm maintaining an application that uses SQL Server Express 2005 as the back end. The application allows users to create new databases and provide the name for the new database.
When the app is loading the default data I make the following SQL call:
DBCC CHECKIDENT('[myDB].[CsSchema].[CsMyDataType]', RESEED) WITH NO_INFOMSGS
The code works fine as long as everything is in English.
But if the user specifies Chinese characters in the database name the call look like this:
DBCC CHECKIDENT('[e安丞北e].[CsSchema].[CsMyDataType]', RESEED) WITH NO_INFOMSGS
This call fails with this error message:
"Could not find database 'e???'. The database either does not exist, or was dropped before a statement tried to use it."
I make many other calls with the database name that work properly. For example, this statement executes without an issue.
SET IDENTITY_INSERT [e安丞北e].[CsSchema].[CsMyDataType] OFF
The error seems to be specific to the DBCC CHECKIDENT call. Any ideas?
Note: I'm running on Chinese version of Windows XP.
Try passing the string as unicode (see KB):
DBCC CHECKIDENT(N'[e安丞北e].[CsSchema].[CsMyDataType]', RESEED) WITH NO_INFOMSGS
Related
When I use the 'Select Top 1000 Rows' function in SSMS in three of the tables in my database, I get an error that the database is offline. But the database name in the error message does not match the name of the database in the query.
SELECT TOP 1000 ...
FROM [vc-live].[dbo].[Errors]
Msg 942, Level 14, State 4, Line 2
Database 'vc-live-old' cannot be opened because it is offline.
If I add an explicit using statement -- either [master] or [vc-live] -- the query runs fine.
The only other weirdness I can find is that the vc-live-old database shows online in sys.master_files though it is offline in SSMS.
As you probably suspect, the database was renamed some time back using an alter statement after placing it in single user mode with rollback immediate.
The application that accesses the database is running fine and I am not concerned with data loss due to the nature of the application. However, I am concerned about what might happen when the database engine is restarted.
DB is 2012 SP2.
Any thoughts on this unexpected behavior?
https://dba.stackexchange.com/questions/48237/renaming-sql-server-database-unusual-result
The execution plans for the SELECT TOP 1000 queries were cached. Per the advice at the above link, I used DBCC FREEPROCCACHE to correct the issue.
Also this post was good if you want to use the command with more finesse: https://sqlserverperformance.wordpress.com/2009/12/28/fun-with-dbcc-freeproccache/
If I set DBCC CHECK to run as part of a job; will the job fail (and subsequently alert me) if an allocation error/consistency error is found?
USE [mydb]
GO
DBCC CHECKDB(N'mydb') WITH NO_INFOMSGS
By the way, if the job fails than there is something wrong with database consistency or resource availability, in either case administrator have to rectify the issue. There is an option of configuring "Alerts" in the job that will trigger an email etc to inform certain group or people, if proper monitoring is not available.
I'm using Crystal Reports 2008 with SQL Server 2014.
I read on the internet that it was possible to create a temporary table with Crystal Reports. This link says that, one of many examples -> Click here
Yet when I go to the database expert, create a new command and enter the following DDL
CREATE TABLE #temp_test (col1 VARCHAR(5))
I get this error
Translation:
database connector error : 'No error message from server'
Yet, when I'm doing that with SQL Server on my database, everything is fine.
Have you managed to do it? If yes, how?
It sounds like an urban legend to me but I might be wrong...
Cheers
When you create a "Command" table in Crystal, you're giving Crystal a set of text to send to the SQL server, and Crystal expects a data set in return. Everything in between is done on the SQL server. Crystal checks the command by sending it to the SQL server when you enter it to see if it works.
Given that, your temp table is actually created on the SQL server. Also, when you create a temp table, it is deleted after the command is finished running.
As a result, if you use only this code, the SQL server will create the table, but there is no data set to return. It succeeds, so doesn't return an error, but also doesn't return data, hence the message: "No error message from server".
For your next step, I would suggest using code like this:
CREATE TABLE #temp_test (col1 VARCHAR(5))
SELECT * FROM #temp_test
This will create an empty data set to return to Crystal, so that it's getting the response it needs. I say this so that you don't think anything is wrong when you don't see anything. You'll need to insert data into the temp table in order to get it from the select statement for visual confirmation.
I would also suggest that you don't use a temp table unless you determine that you do or will actually need one within the scope of the command. For example, you may need one to increase performance on a particularly complex query or CTE, so it might increase performance to use a temp table. But I would create that query first and worry about optimization after I have at least some of it developed.
I am using SQL Server for my web application. How will I know that an insert query failed because the database server memory disk is already full
The error code you will get back will indicate that the disk is full: 1105 (primary filegroup full) or 9902 (log file full)
You can simulate this by disabling the auto-grow feature on the database (It's a checkbox in the database properties on the file tab) and filling up the database. The error will be the same.
ALTER DATABASE YourDatabase
MODIFY FILE (name='YourFile' MAXSIZE=50MB);
if you want to find you memory usage
exec sp_spaceused
This will give you how much memory you are used for particular database
Check the error code you get back from SQL Server when you try to insert into the database.
With that error given back you can then decide what to do. (e.g. Try to insert again,
Try to free up some memory on the server) Also if you havent already, place your Insert statement inside a Transaction so that you can rollback if an error occurs.
I suppose you can believe that if the disk is full the SQL server will return the error code :).
You can make your testing code think it is communicating with the SQL server but instead it will talk to some fake object of yours that will respond with the error codes you want to test.
There are frameworks that can help you. One of them is Rhino Mocks you can download from http://ayende.com
I have a weird problem here.
In short to the environment we have:
There is a (newly set up) Win2003 Server with a SQL Server 2005 Express database. I connect to it via a MS Access application.
Since I switched to the new server (restored a backup from the former server on it) all SPROCs (only in Access) have a ;1 after their name, hence cannot be found.
If I try to open a SPROC in Access (dbl click in overview), it asks for the parameter, then says cannot be found.
If I try to open, say, a report based on it, same result. If I change the name of the SPROC the report is based on to the name shown in the overview ( [sprocnam];1 ) it says "cannot be found" (of course, because the names did not change as one can see in Management Studio).
?!?
keep in mind that the Access-application worked fine with the database that I backed up on another server and restored to the newly set up server ...
Your help is greatly appreciated!
edit: I found a thread on SAP.com with someone experiencing the same problem, but without a solution: https://forums.sdn.sap.com/message.jspa?messageID=7947957
I can't tell why you have got this issue, but in In SQL Server you have the ability to create Numbered stored procedures. The procedures have the same name but may contain completely different code, look at this:
CREATE PROCEDURE [dbo].[spTest]
AS
BEGIN
SELECT ##MICROSOFTVERSION
END
GO
CREATE PROCEDURE [dbo].[spTest];2
AS
SELECT ##version
GO
EXEC spTest;1
EXEC spTest;2
I resolved the issue with an update of the clients office-installation to the latest service pack.
The one employee that notified me of the problem and me got new computers last week, and thus did not have the latest updates.