Showing posts with label store. Show all posts
Showing posts with label store. Show all posts

Thursday, March 22, 2012

Can not connect to Database

I'm using SQL Server 2000
I'm trying to store a database to a test database as I have done in the
past, now I'm getting an error message saying "Exclusive access could not be
obtained because the database is in use. RESTORE DATABASE is terminating
abnormally."
No is using this test database. Could someone tell me what is causing this
error and how can I solve this problem.
Thank you in advance,
More than likely you have EM or QA pointing to it. In EM make sure you
click on an active node other than the db in question. Run sp_who2 or
sp_lock to see which spid is accessing the db.
Andrew J. Kelly SQL MVP
"Kevin" <Kevin@.discussions.microsoft.com> wrote in message
news:AE0CE4C0-2342-444E-8128-28795F6F1F7D@.microsoft.com...
> I'm using SQL Server 2000
> I'm trying to store a database to a test database as I have done in the
> past, now I'm getting an error message saying "Exclusive access could not
> be
> obtained because the database is in use. RESTORE DATABASE is terminating
> abnormally."
> No is using this test database. Could someone tell me what is causing this
> error and how can I solve this problem.
> Thank you in advance,
>

Can not connect to Database

I'm using SQL Server 2000
I'm trying to store a database to a test database as I have done in the
past, now I'm getting an error message saying "Exclusive access could not be
obtained because the database is in use. RESTORE DATABASE is terminating
abnormally."
No is using this test database. Could someone tell me what is causing this
error and how can I solve this problem.
Thank you in advance,More than likely you have EM or QA pointing to it. In EM make sure you
click on an active node other than the db in question. Run sp_who2 or
sp_lock to see which spid is accessing the db.
Andrew J. Kelly SQL MVP
"Kevin" <Kevin@.discussions.microsoft.com> wrote in message
news:AE0CE4C0-2342-444E-8128-28795F6F1F7D@.microsoft.com...
> I'm using SQL Server 2000
> I'm trying to store a database to a test database as I have done in the
> past, now I'm getting an error message saying "Exclusive access could not
> be
> obtained because the database is in use. RESTORE DATABASE is terminating
> abnormally."
> No is using this test database. Could someone tell me what is causing this
> error and how can I solve this problem.
> Thank you in advance,
>

Monday, March 19, 2012

Can multiple apps connect to the same database?

I have an application that was developed under Visual Basic .NET 2005 Standard that I keep continuously running to monitor and gather data and store that data in a SQL Server Express database. This is all done on a single computer that's not networked to anything. The trouble is, I'd like to look at the data in the database from time to time without shutting down the application, but I'm not able to do so. If I try to copy the database files, named lamination.mdf and lamination.ldf, to another location, I get the following error message;

"Cannot copy lamination: There has been a sharing violation. The source or destination file may be in use."

I would like to be able to copy the file to my office computer where it would be convenient to use Management Studio Express to look at the database tables. I can't even use Management Studio Express on the computer where the application is running, as I get the following message when I try to attach the database:

"CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf'. (Microsoft SQL Server, Error: 5123)"

Here is the connection string in the VB application:

"Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf";Integrated Security=True;User Instance=True"

In the VB app, connections to the database are made only every few minutes, and the connections are immediately closed.

Is there anyway I can either copy the database files, or at least look at the database tables with Management Studio Express without stopping the VB application?

Thanks,

Tim

Multiple connections to user instances are not possible. Attach the database to the Express instances to make that possible.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de
|||

Jens, I'm confused. You say that multiple connections to user instances are not possible, but then you say to attach the database to the Express intances to make that possible. Is it possible or not? And if it is possible, could you go into more detail to explain how?

Thanks,

Tim

|||You'd need to shut down SQL before you can copy the files.|||I would suggest reading something about the priciples of user instance and regular SQl Server instances. SQL Server instances are permanatly attached to the SQL Server service, while user instances are only attached during the usage of any application. If one application gains access to the file, it is opened exclusivly for the user, therefore cannot be opened through another user instance connection. The Server permanently attached file on the other site will allow though the service to handle multiple user requests.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||I would be careful which such assumptions. Sure the files can be copied during the usage, but shutting down SQL Server will make the datafile be consistent. If you do not shut down the server service, the information of datafile and logfile can differ making the database after a restore inaccessible. So the better way would be to shutdown the service and therefore close the files.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlexprbol/html/0bd6143a-ca9d-4f36-ae23-bd35a2d22d70.htm

Basically, the application needs to be running first, and then you connect to the user instance with a named pipe protocol. However, the Select statement they use in the example didn't work for me as is;

Select owning_principle_name, instance_pipe_name from sys.dm_os_child_instances

I had to drop the field names and use this

Select * from sys.dm_os_child_instances

Then, from the new connection listed in the object explorer I drilled down to the folder containing the user instance database (the folder name having the same path as my application's database) and was able to "manage objects related to your user instance" as they put it.

Tim

Can multiple apps connect to the same database?

I have an application that was developed under Visual Basic .NET 2005 Standard that I keep continuously running to monitor and gather data and store that data in a SQL Server Express database. This is all done on a single computer that's not networked to anything. The trouble is, I'd like to look at the data in the database from time to time without shutting down the application, but I'm not able to do so. If I try to copy the database files, named lamination.mdf and lamination.ldf, to another location, I get the following error message;

"Cannot copy lamination: There has been a sharing violation. The source or destination file may be in use."

I would like to be able to copy the file to my office computer where it would be convenient to use Management Studio Express to look at the database tables. I can't even use Management Studio Express on the computer where the application is running, as I get the following message when I try to attach the database:

"CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf'. (Microsoft SQL Server, Error: 5123)"

Here is the connection string in the VB application:

"Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf";Integrated Security=True;User Instance=True"

In the VB app, connections to the database are made only every few minutes, and the connections are immediately closed.

Is there anyway I can either copy the database files, or at least look at the database tables with Management Studio Express without stopping the VB application?

Thanks,

Tim

Multiple connections to user instances are not possible. Attach the database to the Express instances to make that possible.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de|||

Jens, I'm confused. You say that multiple connections to user instances are not possible, but then you say to attach the database to the Express intances to make that possible. Is it possible or not? And if it is possible, could you go into more detail to explain how?

Thanks,

Tim

|||You'd need to shut down SQL before you can copy the files.|||I would suggest reading something about the priciples of user instance and regular SQl Server instances. SQL Server instances are permanatly attached to the SQL Server service, while user instances are only attached during the usage of any application. If one application gains access to the file, it is opened exclusivly for the user, therefore cannot be opened through another user instance connection. The Server permanently attached file on the other site will allow though the service to handle multiple user requests.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||I would be careful which such assumptions. Sure the files can be copied during the usage, but shutting down SQL Server will make the datafile be consistent. If you do not shut down the server service, the information of datafile and logfile can differ making the database after a restore inaccessible. So the better way would be to shutdown the service and therefore close the files.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlexprbol/html/0bd6143a-ca9d-4f36-ae23-bd35a2d22d70.htm

Basically, the application needs to be running first, and then you connect to the user instance with a named pipe protocol. However, the Select statement they use in the example didn't work for me as is;

Select owning_principle_name, instance_pipe_name from sys.dm_os_child_instances

I had to drop the field names and use this

Select * from sys.dm_os_child_instances

Then, from the new connection listed in the object explorer I drilled down to the folder containing the user instance database (the folder name having the same path as my application's database) and was able to "manage objects related to your user instance" as they put it.

Tim

Can multiple apps connect to the same database?

I have an application that was developed under Visual Basic .NET 2005 Standard that I keep continuously running to monitor and gather data and store that data in a SQL Server Express database. This is all done on a single computer that's not networked to anything. The trouble is, I'd like to look at the data in the database from time to time without shutting down the application, but I'm not able to do so. If I try to copy the database files, named lamination.mdf and lamination.ldf, to another location, I get the following error message;

"Cannot copy lamination: There has been a sharing violation. The source or destination file may be in use."

I would like to be able to copy the file to my office computer where it would be convenient to use Management Studio Express to look at the database tables. I can't even use Management Studio Express on the computer where the application is running, as I get the following message when I try to attach the database:

"CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf'. (Microsoft SQL Server, Error: 5123)"

Here is the connection string in the VB application:

"Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\tbarnard\My Documents\Visual Studio 2005\Projects\Lamination Phase I\LamDataBase\Lamination.mdf";Integrated Security=True;User Instance=True"

In the VB app, connections to the database are made only every few minutes, and the connections are immediately closed.

Is there anyway I can either copy the database files, or at least look at the database tables with Management Studio Express without stopping the VB application?

Thanks,

Tim

Multiple connections to user instances are not possible. Attach the database to the Express instances to make that possible.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de|||

Jens, I'm confused. You say that multiple connections to user instances are not possible, but then you say to attach the database to the Express intances to make that possible. Is it possible or not? And if it is possible, could you go into more detail to explain how?

Thanks,

Tim

|||You'd need to shut down SQL before you can copy the files.|||I would suggest reading something about the priciples of user instance and regular SQl Server instances. SQL Server instances are permanatly attached to the SQL Server service, while user instances are only attached during the usage of any application. If one application gains access to the file, it is opened exclusivly for the user, therefore cannot be opened through another user instance connection. The Server permanently attached file on the other site will allow though the service to handle multiple user requests.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||I would be careful which such assumptions. Sure the files can be copied during the usage, but shutting down SQL Server will make the datafile be consistent. If you do not shut down the server service, the information of datafile and logfile can differ making the database after a restore inaccessible. So the better way would be to shutdown the service and therefore close the files.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de|||

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

Jens,

I found one way to connect to, and examine, a database with Sequel Server Management Studio Express, while it is being used by another application with a user instance. It is described at the following link, under the heading "Connecting to a SQL Server Express user instance":

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlexprbol/html/0bd6143a-ca9d-4f36-ae23-bd35a2d22d70.htm

Basically, the application needs to be running first, and then you connect to the user instance with a named pipe protocol. However, the Select statement they use in the example didn't work for me as is;

Select owning_principle_name, instance_pipe_name from sys.dm_os_child_instances

I had to drop the field names and use this

Select * from sys.dm_os_child_instances

Then, from the new connection listed in the object explorer I drilled down to the folder containing the user instance database (the folder name having the same path as my application's database) and was able to "manage objects related to your user instance" as they put it.

Tim

Thursday, March 8, 2012

Can IIF() function be used in SELECT statment?

I try to use IIF() function in SELECT statmenmt in a store procedure
difination.
SELECT iif( month(ref_date)=1 , 1 , 0 )
FROM MyTable
But the system always show me
Incorrect syntax near '='
What's the corect syntax of iif function?
Thank you.Hi!
There is no IIF function in T-SQL, but you can use CASE expression instead.
Do please look for the syntax in Books OnLine.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Xiaotao, Lu" <luxiaotao@.hotmail.com> wrote in message
news:eLm9ieCAEHA.1608@.TK2MSFTNGP11.phx.gbl...
> I try to use IIF() function in SELECT statmenmt in a store procedure
> difination.
> SELECT iif( month(ref_date)=1 , 1 , 0 )
> FROM MyTable
> But the system always show me
> Incorrect syntax near '='
> What's the corect syntax of iif function?
> Thank you.
>|||Use CASE:
SELECT CASE WHEN MONTH(ref_date)=1 THEN 1 ELSE 0 END
FROM MyTable
David Portas
SQL Server MVP
--

Can IIF() function be used in SELECT statment?

I try to use IIF() function in SELECT statmenmt in a store procedure
difination.
SELECT iif( month(ref_date)=1 , 1 , 0 )
FROM MyTable
But the system always show me
Incorrect syntax near '='
What's the corect syntax of iif function?
Thank you.Hi!
There is no IIF function in T-SQL, but you can use CASE expression instead.
Do please look for the syntax in Books OnLine.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Xiaotao, Lu" <luxiaotao@.hotmail.com> wrote in message
news:eLm9ieCAEHA.1608@.TK2MSFTNGP11.phx.gbl...
> I try to use IIF() function in SELECT statmenmt in a store procedure
> difination.
> SELECT iif( month(ref_date)=1 , 1 , 0 )
> FROM MyTable
> But the system always show me
> Incorrect syntax near '='
> What's the corect syntax of iif function?
> Thank you.
>|||Use CASE:
SELECT CASE WHEN MONTH(ref_date)=1 THEN 1 ELSE 0 END
FROM MyTable
--
David Portas
SQL Server MVP
--

Saturday, February 25, 2012

Can I use Hyperlinks in a SQL Server CE database?

Is it possible to store a hyperlink in a SQL Server Compact Edition Database?

Specifically, I would like to have the link point to an .jpg file stored in a folder on the computer.

Thanks!The "hyperlink" field type is not supported, by you can store text in a SQL CE database, both the Hyperlink description and the file path (in 2 nvarchar fields)

can i use a store procedure as default value for a column?

Is it possible to use a stored procedure to fill the default value of a column when i'm building the db?

i mean if i can use a stored procedure for the "colum property": "default value or bnding"

if yes how can i do it?

No, you won't be able to specify a stored procedure in your table definition as a default value for a column. Your best bet for this is to set up a trigger (either AFTER or INSTEAD OF) to enforce the default value.

|||

You can, however, use a scalar user-defined function as the default value. So if you can convert the sproc to a UDF or call it from one, you're good to go.

Don

Friday, February 24, 2012

Can I store the result set of sp_who command in a table

Hi,
I want to loop through the records of the result set of sp_who.
Can this be done? How it can be done?
Regards,
Sevugan.C
code:

create table #tmpSpWho
(
spid smallint
,ecid smallint
,status nchar(30)
,loginame nchar(128)
,hostname nchar(128)
,blk char(5)
,dbname nchar(128)
,cmd nchar(16)
)
insert into #tmpSpWho
exec sp_who


HTH,
Cristian Lefter, SQL Server MVP
"Sevugan" <
Sevugan@.discussions.microsoft.com>
wrote in message
news:41413280-9A1A-481D-9FC8-31642E546811@.microsoft.com...
>
Hi,
>
I want to loop through the records of the result set of sp_who.
>
Can this be done? How it can be done?
>
>
Regards,
>
>
Sevugan.C|||You can create a temporary table to grab the result from the sp sp_who2.
Example:
use northwind
go
create table #t1 (
spid int,
status varchar(255),
login sysname,
hostname sysname,
blkby sysname,
dbname varchar(128),
command varchar(255),
cputime int,
diskio int,
lastbatch varchar(35),
programname varchar(128),
spid_1 int
)
go
insert into #t1
exec sp_who2
go
select
*
from
#t1
order by
login
go
drop table #t1
go
AMB
"Sevugan" wrote:

> Hi,
> I want to loop through the records of the result set of sp_who.
> Can this be done? How it can be done?
> Regards,
> Sevugan.C|||If you are wanting to do this on the client side, you can call sp_who into
an ADO recordset the same as any stored procedure.
"Sevugan" <Sevugan@.discussions.microsoft.com> wrote in message
news:41413280-9A1A-481D-9FC8-31642E546811@.microsoft.com...
> Hi,
> I want to loop through the records of the result set of sp_who.
> Can this be done? How it can be done?
> Regards,
> Sevugan.C|||Create TABLE #WHO
(
spid int,
ecid int,
Status Nvarchar(20),
LoginName Nvarchar(30),
Hostname Nvarchar(30),
blk int,
dbname Nvarchar(30),
cmd Nvarchar(255)
)
Insert #who
EXEC sp_who
Select * from #who
Create cursor to loop through data with whatever you want to do with the dat
a.
Hope this helps.
"Sevugan" wrote:

> Hi,
> I want to loop through the records of the result set of sp_who.
> Can this be done? How it can be done?
> Regards,
> Sevugan.C

Can I store a file in a SQL Server Database?

I have SQL Server 2000 and I have to make a table for storing Word, Excel or maybe some other Microsoft Office files. What data type should I use for this? Can I search through the stored files by words in a stored documents using a query and how?
Also the database where this table is created should provide similar functionality as a file server open, edit, check in, and check out on stored files. Can I do this in SQL Server 2000?As fare as I know, SQL Server has no specific support for office files.

So, you have the choice between re-inventing the functionality of document information systems, or to buy some. These systems are storing office files as BLOBs to keep all controls, and they are storing the text in a separate TEXT field to enable searching.

However, there is a third way: store only the path to the documents on your netwerk, and use Office's functionality to prevent users to open the same document twice.

Can I store a file in a SQL Server Database?

I have SQL Server 2000 and I have to make a table for storing Word, Excel or maybe some other Microsoft Office files. What data type should I use for this? Can I search through the stored files by words in a stored documents using a query and how?
Also the database where this table is created should provide similar functionality as a file server open, edit, check in, and check out on stored files. Can I do this in SQL Server 2000?You can store documents in the text or image data type.

You probably can't search on them, but your could store a summary in a character-based field with the record, or a column that just contains keywords.

Yes, you can provide functionality similar to a file-server...you just have to write it all yourself. :(

I can tell you that you are looking at a daunting project here that will likely involve complex coding. The user-interface will probably also prove difficult.

Perhaps somebody else on the forum will see this post and could recommend some professionally designed 3rd party software for document management?

blindman

Sunday, February 19, 2012

can I send a variable table name

Hi every one,
Can i send a variable table name in to the store procedure
in ORACLE8i
eg
create procedure sample
(x as numeric, table_name as varchar(150))
is begin
if x = 1 then
select * from table_name;
end if;
end;
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
On Fri, 18 Mar 2005 00:16:06 -0800, Param N wrote:

>Hi every one,
>Can i send a variable table name in to the store procedure
>in ORACLE8i
(snip)
Hi Param8,
You'd better ask in a newsgroup for Oracle. This group is for Microsoft
SQL Server.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

can I send a variable table name

Hi every one,
Can i send a variable table name in to the store procedure
in ORACLE8i
eg
create procedure sample
(x as numeric, table_name as varchar(150))
is begin
if x = 1 then
select * from table_name;
end if;
end;
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!On Fri, 18 Mar 2005 00:16:06 -0800, Param N wrote:

>Hi every one,
>Can i send a variable table name in to the store procedure
>in ORACLE8i
(snip)
Hi Param8,
You'd better ask in a newsgroup for Oracle. This group is for Microsoft
SQL Server.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

can I send a variable table name

Hi every one,
Can i send a variable table name in to the store procedure
in ORACLE8i
eg
create procedure sample
(x as numeric, table_name as varchar(150))
is begin
if x = 1 then
select * from table_name;
end if;
end;
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!On Fri, 18 Mar 2005 00:16:06 -0800, Param N wrote:
>Hi every one,
>Can i send a variable table name in to the store procedure
>in ORACLE8i
(snip)
Hi Param8,
You'd better ask in a newsgroup for Oracle. This group is for Microsoft
SQL Server.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Friday, February 10, 2012

Can I link 2 tables from 2 different SQL Servers ?

I know that 2 tables from 2 databases can be join together. But how about 2 tables from 2 databases which are store separately on 2 different SQL servers . Can this be done ?You can create a linked server and join the tables using the 4 part sytax

select *
from svr1.db1.owner1.tbl1 tbl1
join svr2.db2.owner2.tbl2 tbl2
on tbl1.fld1 = tbl2.fld2

Be careful though as the data will have to be sent to one of the servers to do the join.
Setting collation compatability for the linked server will also affect this.|||Will this effect the performance of the servers ?

Will joining 2 SQL servers improve the performance of a query that was previously having performance problems ?|||>> Be careful though as the data will have to be sent to one of the servers to do the join.

It will probably be very slow.

Can i invoke remoting web service in store procedure directly?

i am using sqlserver 2000,if so how,thanks.Nope. But you'll be able to do it Yukon.

Rob|||Hi mmkk,

I saw a similar discussion about invoking Web Services in TSQL in the past:
here

Regards,

Can I install to C and put data on E?

Can I install SQL Express 2005 to C drive but store and run the database from a different partition on the same drive?

Thanks in advance.

Yes you can.

When installing from a command line, you can supply the INSTALLSQLDATADIR command to provide a non-default data location. You can also set this after SQL has been installed using the Database Properties tab of the Server Properties dialog.

Mike