Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Thursday, March 29, 2012

Create and Edit flat file from Sqlserver (SP).

HI All,
I use sqlserver2000 server.
I have a requirement to create a flat file(.txt) and dump the data into the file with some formatting.
I tried to use DTS but,
1. it doesnt allow me to put one row information of table to multiple line in the flat file.
2. Dynamically we cannot create n number of files we need from DTS.

Now, i am trying to create a file from sql server Stored Procedure and write data into it.

Can any one help me..
How to create and write to file from sqlserver (sp) .

Regards

Abdul lateef.Originally posted by a_lateef

I tried to use DTS but,
1. it doesnt allow me to put one row information of table to multiple line in the flat file.
2. Dynamically we cannot create n number of files we need from DTS.


Maybe if you add a ActiveX script step in the DTS package. Hope someone else can explain further...|||Greetings!

I personally would just write a script (pick a language of choice) to pull the data from the server, format it and then write it to a textfile. Although there are ways to do it in SQL Server it is very cumbersome and I think you will find that just about any other language will offer a lot more flexibility in this case. If you use something like a Visual Basic Script file you could then just set it up as a job to run when it was supposed to.

Maybe someone else could offer something else on this, good luck!

HTH!|||I am unclear as to what you want in the text file - could you explain in detail (what are your requirements) - maybe with an example.

create and attach data base

Hi, i want to create a database with out the LOG file I did not find a way to do that, I want to create database in 2 ways

1. With CREATE DATABASE command.

2.Attach an exsiting MDF file.

is there any way i can do that, my problem is that i'm creating the data base on my local computer the using sp_detach_db to detach the DB files, then trying to attach DB files from remote computer on the LAN that i dont have write premmsion on, but then i get an error from SQL server saying:

"[Microsoft][SQL Native Client][SQL Server]Unable to open the physical file "\\lab11\sqltest\pppSignaling_log.ldf". Operating system error 5: "5(Access is denied.)"."

what can i do to solve this problem?

thanks ishay

More about storage in network path in SQL Server can be found here:

http://support.microsoft.com/kb/304261/en-us

Generally spoken, this is not supported.

HTH, Jens Suessmeyer.

http://www.slqserver2005.de

Create an XML file from a stored procedure

I'm trying to create a temp xml file to to convert it eventually into an excel file.

using C#

I am calling a stored procedure and from that data retrieved I want to write it in xml format.

I tried using the xmlTextWriter.. but I get an exception, it refers to a token..(?)

I am new to using xml, so any help would be great..

Can I write an xml file by using a streamWriter or writing all bytes?

Thanks,

kt

You haven't mentioned if you are using SQL Server 2000 or 2005.
If its 2000, then check the FOR XML {AUTO, RAW, EXPLICIT} syntax in books online.
If its 2005 you might want to use the FOR XML PATH.

These will return for you the results in the XML format you want and you might not really need to format it manually using C#.

Hope that helps!
|||

I'm using SQL Server 2005...

You wouldn't possibly know any good resources on formatting.. for using "FOR XML PATH"..?

sql

Create an XML file from a stored procedure

I'm trying to create a temp xml file to to convert it eventually into an excel file.

using C#

I am calling a stored procedure and from that data retrieved I want to write it in xml format.

I tried using the xmlTextWriter.. but I get an exception, it refers to a token..(?)

I am new to using xml, so any help would be great..

Can I write an xml file by using a streamWriter or writing all bytes?

Thanks,

kt

You haven't mentioned if you are using SQL Server 2000 or 2005.
If its 2000, then check the FOR XML {AUTO, RAW, EXPLICIT} syntax in books online.
If its 2005 you might want to use the FOR XML PATH.

These will return for you the results in the XML format you want and you might not really need to format it manually using C#.

Hope that helps!
|||

I'm using SQL Server 2005...

You wouldn't possibly know any good resources on formatting.. for using "FOR XML PATH"..?

Create an index in a PDF file

Hi!!

I have a report that is exported to a PDF file... Is possible to get an index in the beginning of the file? I have the page number at the bottom of each page but i would need an index...

Thx in advance!!

Any idea? Isn′t possible to do it? At the moment, I havent found anything linked with this...|||

Hi Sergio,

Do you mean a document map? Check out this link: http://msdn2.microsoft.com/en-us/library/ms156383.aspx

|||

Hi Brad!!

not exactly... i would like to appear something similar but in a page in the beginning of the PDF document including the page number where each element is, i.e. the tables of the document... is there any option to do this? it′s very similar to the document map but with the page number...

I see two problems:

- I was thinking of using "=Globals.PageNumber" but i can′t, it says me that only can be placed in the header or the footer...

- and the other problem is setting the content of the document map in a page of the PDF... could I do this?

Perhaps, this is a bit difficult but I am always looking for challenges ... any suggestions? thx in advance!!

Sergio

|||I know of no way to accomplish exactly what you are looking for sorry to say. The document map links to items as repeated on pages. But I am not sure what you mean by "setting the content of the document map in a page of the PDF". If you mean as a page, there is no way to control this.|||

Hi Brad,

that was exactly i ment: i want to show it as a page, but if there is no way to do it... anyway, thank you for your help...

Sergio

Tuesday, March 27, 2012

Create a txt file and rename the file from a SP

I can populate a txt file using DTS.
How do i Rename the file using data from the table using
DTS or a stored procedure?You could rename the file using DTS :-
http://www.sqldts.com/default.aspx?292
You could also use the xp_cmdshell stored proc
--
HTH
Ryan Waight, MCDBA, MCSE
"Brian" <anonymous@.discussions.microsoft.com> wrote in message
news:092701c3a51d$bc93bfe0$a401280a@.phx.gbl...
> I can populate a txt file using DTS.
> How do i Rename the file using data from the table using
> DTS or a stored procedure?

Create a Text File

Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'Consider making a small DTS package with the stored proc as the SQL for the
Data Pump. Have SQL Server execute the package.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
<varkey.mathew@.wipro.com> wrote in message
news:1147823437.443893.165480@.i39g2000cwa.googlegroups.com...
Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'

Create a Text File

Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'Consider making a small DTS package with the stored proc as the SQL for the
Data Pump. Have SQL Server execute the package.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
<varkey.mathew@.wipro.com> wrote in message
news:1147823437.443893.165480@.i39g2000cwa.googlegroups.com...
Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'

Create a Text File

Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'Consider making a small DTS package with the stored proc as the SQL for the
Data Pump. Have SQL Server execute the package.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
<varkey.mathew@.wipro.com> wrote in message
news:1147823437.443893.165480@.i39g2000cwa.googlegroups.com...
Dear all,
I wanted to create a text file to be passed as input to a Mainframe
system. I have created an SP with the query to create the data exactly
in the requisite format. I need to be creating the text file from
within SQL Server only. I have used osql utility to achieve this and it
works.. However, it adds a couple of extra new lines in the end of the
text file, which is not acceptable to Mainframe system.. Is there any
way I can get rid of the 2 additional lines in the end of the file? Or
is there another way to do this?
I would really appreciate a quick response..
Best regards,
Varkey
PS: I am using master..xp_cmdshell to execute the osql statement. I am
using SQL Server 2000
osql format is 'osql -Q"EXEC mysp" -o c:\test.txt -h-1 -s"" -Smyserver
-dmydb -E'

create a table prior to bcping data

I need to do the following;
1. bcp out data from our reporting server
2. Move bcp file to our archival server
Sounds pretty straight forward.. but of course there is
more...
Since we are using this data for archival purposes, we
just want to store the bcp file. My concern is that there
are many schema changes to the source table and I wanted
to make sure that I had the correct schema needed to bcp
that file back into a table, say three years from now.
Is there a option in bcp or bulk copy that would create
the schema for you? Or can this be done via DTS?
Thanks in advance
Susan
Any help would be greatly appreciated.
Thanks
Susan
Hi,
You can "Generate a script " of all objects and keep it along with the BCP
OUT data.
How to Generate scripts:
1. In Enterprise manager
2. Connect to the SQL server
3. Select the database you need to generate the script
4. Right click All Tasks - "Select the Generate SQL Script" option
5. Click Show all
6. Go to Options Tab - in the Table options select Script INdexes, Triggers
and Primary keys.../
Click the save button and save the file to your hard disk in safe place.
Once you require create a ne database and Execute this script
and BCP IN the the data back.
Thanks
Hari
MCDBA
"Susan" <anonymous@.discussions.microsoft.com> wrote in message
news:1a40701c41db3$13400250$a501280a@.phx.gbl...
> I need to do the following;
> 1. bcp out data from our reporting server
> 2. Move bcp file to our archival server
> Sounds pretty straight forward.. but of course there is
> more...
> Since we are using this data for archival purposes, we
> just want to store the bcp file. My concern is that there
> are many schema changes to the source table and I wanted
> to make sure that I had the correct schema needed to bcp
> that file back into a table, say three years from now.
> Is there a option in bcp or bulk copy that would create
> the schema for you? Or can this be done via DTS?
> Thanks in advance
> Susan
>
>
> Any help would be greatly appreciated.
> Thanks
> Susan
>

create a table prior to bcping data

I need to do the following;
1. bcp out data from our reporting server
2. Move bcp file to our archival server
Sounds pretty straight forward.. but of course there is
more...
Since we are using this data for archival purposes, we
just want to store the bcp file. My concern is that there
are many schema changes to the source table and I wanted
to make sure that I had the correct schema needed to bcp
that file back into a table, say three years from now.
Is there a option in bcp or bulk copy that would create
the schema for you? Or can this be done via DTS?
Thanks in advance
Susan
Any help would be greatly appreciated.
Thanks
SusanHi,
You can "Generate a script " of all objects and keep it along with the BCP
OUT data.
How to Generate scripts:
1. In Enterprise manager
2. Connect to the SQL server
3. Select the database you need to generate the script
4. Right click All Tasks - "Select the Generate SQL Script" option
5. Click Show all
6. Go to Options Tab - in the Table options select Script INdexes, Triggers
and Primary keys.../
Click the save button and save the file to your hard disk in safe place.
Once you require create a ne database and Execute this script
and BCP IN the the data back.
Thanks
Hari
MCDBA
"Susan" <anonymous@.discussions.microsoft.com> wrote in message
news:1a40701c41db3$13400250$a501280a@.phx.gbl...
> I need to do the following;
> 1. bcp out data from our reporting server
> 2. Move bcp file to our archival server
> Sounds pretty straight forward.. but of course there is
> more...
> Since we are using this data for archival purposes, we
> just want to store the bcp file. My concern is that there
> are many schema changes to the source table and I wanted
> to make sure that I had the correct schema needed to bcp
> that file back into a table, say three years from now.
> Is there a option in bcp or bulk copy that would create
> the schema for you? Or can this be done via DTS?
> Thanks in advance
> Susan
>
>
> Any help would be greatly appreciated.
> Thanks
> Susan
>|||I've found a solution to my issue and wanted to let you
all know!!
I had also posted my question on the SQL Server Central
site and Mr. Mortensen was nice enough to provide a GENIUS
solution. He has a proc that will
1. Generate schema of the table in question
2. Update stats on table prior to BCPing
3. BCP's out the data into a readable text file
4. Verify row counts from the BCP and the actual table
(VERY NICE)
5. He also has a bat file that will run the schema and bcp
the data into the DB/table of your choice.
It was EXACTLY what I need and I want to thank him for his
help.
BTW - Why did Microsoft get rid of the backup 'table'
option? I used it quite a bit in 6.5 and there are MANY
time you only need to save one table and not the whole
database. I know there is dts and bcp, but nothing
compares to backing up and restoring a table. Other DBMS
provide this.. Just wondering.
Thanks
Susan
Here's the link in case your curious.
http://www.sqlservercentral.com/forums/shwmessage.aspx?
forumid=8&messageid=111276
>--Original Message--
>I need to do the following;
>1. bcp out data from our reporting server
>2. Move bcp file to our archival server
>Sounds pretty straight forward.. but of course there is
>more...
>Since we are using this data for archival purposes, we
>just want to store the bcp file. My concern is that there
>are many schema changes to the source table and I wanted
>to make sure that I had the correct schema needed to bcp
>that file back into a table, say three years from now.
>Is there a option in bcp or bulk copy that would create
>the schema for you? Or can this be done via DTS?
>Thanks in advance
>Susan
>
>
>Any help would be greatly appreciated.
>Thanks
>Susan
>.
>

create a table prior to bcping data

I need to do the following;
1. bcp out data from our reporting server
2. Move bcp file to our archival server
Sounds pretty straight forward.. but of course there is
more...
Since we are using this data for archival purposes, we
just want to store the bcp file. My concern is that there
are many schema changes to the source table and I wanted
to make sure that I had the correct schema needed to bcp
that file back into a table, say three years from now.
Is there a option in bcp or bulk copy that would create
the schema for you? Or can this be done via DTS?
Thanks in advance
Susan
Any help would be greatly appreciated.
Thanks
SusanHi,
You can "Generate a script " of all objects and keep it along with the BCP
OUT data.
How to Generate scripts:
1. In Enterprise manager
2. Connect to the SQL server
3. Select the database you need to generate the script
4. Right click All Tasks - "Select the Generate SQL Script" option
5. Click Show all
6. Go to Options Tab - in the Table options select Script INdexes, Triggers
and Primary keys.../
Click the save button and save the file to your hard disk in safe place.
Once you require create a ne database and Execute this script
and BCP IN the the data back.
Thanks
Hari
MCDBA
"Susan" <anonymous@.discussions.microsoft.com> wrote in message
news:1a40701c41db3$13400250$a501280a@.phx
.gbl...
> I need to do the following;
> 1. bcp out data from our reporting server
> 2. Move bcp file to our archival server
> Sounds pretty straight forward.. but of course there is
> more...
> Since we are using this data for archival purposes, we
> just want to store the bcp file. My concern is that there
> are many schema changes to the source table and I wanted
> to make sure that I had the correct schema needed to bcp
> that file back into a table, say three years from now.
> Is there a option in bcp or bulk copy that would create
> the schema for you? Or can this be done via DTS?
> Thanks in advance
> Susan
>
>
> Any help would be greatly appreciated.
> Thanks
> Susan
>

Create a table and put it in a file

When I create a table I can create it in a filegroup, but how do I put it in a file. Example

I have two files in one filegroup called "Secondary" file A and file B.

I want to create a new table called tableA and put it in file B on filegroup Secondary.

I looked at bookes online and can't find it.

Thanks

Thomas

Hi,

It's part of the CREATE TABLE syntax.

CREATE TABLE myTable
(myID int)
ON [Secondary]

You cannot control on which file you create it because different files in a filegroup is exactly for spreading the table over multiple files.

Kind regards

Sunday, March 25, 2012

Create a PDF file directly to disk?

Hello all,

I use Reporting Services and an aspx page to create a PDF file. I need to save the file directly to a disk file with a name, without asking the user if he want to open or to save it. I'm using the folowing command:

Response.WriteFile("http://" & System.Environment.MachineName & "/ReportServer?%2fReportsApp%2fRptFSUnicoR&rs%3aCommand=Render&rs%3aFormat=PDF&MyID=" & IDFun,True)

Any idea how I do that?

Regards

HttpResponse.WriteFile requires either an absolute or virtual path to a sever-local filesystem location. So, referencing the URL of the report server won't work.

Also, I don't think you'll be able to bypass any browser's download prompt dialog without employing some sort of trusted control to do the HTTP request and file saving for you behind the scenes. SoftArtisans XFile is one such product that can do this.

-Chris

|||

Hi Chris,

Thank you for your answer. I'm afraid I will have to think in another solution.

As Report is generated from Reporting Services I thought I could have another parameter to force the "save" at the time I render the Report.

Best regards

sql

Create A New UserName

I am using the following ConnectionString in an ASP file so that the ASP
application can communicate with SQL Server 7.0:
CONNECTIONSTRING="Provider=SQLOLEDB;User ID=SoGuest;Password=SoGuest;
Persist Security
Info=True;Initial Catalog=ForestDB;Data Source=MyServer"
In order to ensure that my ASP page interacts with the database ForestDB, I
have to create a new user named SoGuest whose password will be SoGuest. To
do this, I went to 'Users' under the ForestDB tree, right-clicked & then
clicked 'New Database User'. A dialog box opened up. Next when I clicked the
drop-down list for assigning a login name, I find that there's not a single
login name in the drop-down list as a result of which I am not being allowed
to proceed forward to create the new user SoGuest. How do I create this new
user? Please note that when I try to create a new user in some other DB like
Pubs, Northwind etc. I am given 'BUILTIN\Administrators' as an option in the
drop-down list of the login name. The authentication mode I am using is both
SQL Server & Windows NT (I am working on Windows 2000 Professional).
Thanks,
ArpanIt sounds as though you have not yet created a login. In Enterprise Manager
open up the Security container and right-click Logins. Create a new login
called whatever you want. Assign him to those databases you want him to
access. That will create both your login and database user.
A login allows someone to be verified when they connect to SQL. It is an
entry in the sysxlogins table in the Master db.
A User is someone who already has a login in the sysxlogins table, but
requires access to a specific database. They are placed in the sysusers
table in the particular database they are trying to access.
The Enterprise Manager dialog allows you to add a login and user at the same
time.
HTH
Bob
--
Warning: Do not look into the light sabre whilst switching it on
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003|||You need to create the login in the Security folder first (and you can create the user as well from
that dialog).
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Arpan" <arpan_de@.hotmail.com> wrote in message news:%23JLbRLchDHA.2420@.TK2MSFTNGP10.phx.gbl...
> I am using the following ConnectionString in an ASP file so that the ASP
> application can communicate with SQL Server 7.0:
> CONNECTIONSTRING="Provider=SQLOLEDB;User ID=SoGuest;Password=SoGuest;
> Persist Security
> Info=True;Initial Catalog=ForestDB;Data Source=MyServer"
> In order to ensure that my ASP page interacts with the database ForestDB, I
> have to create a new user named SoGuest whose password will be SoGuest. To
> do this, I went to 'Users' under the ForestDB tree, right-clicked & then
> clicked 'New Database User'. A dialog box opened up. Next when I clicked the
> drop-down list for assigning a login name, I find that there's not a single
> login name in the drop-down list as a result of which I am not being allowed
> to proceed forward to create the new user SoGuest. How do I create this new
> user? Please note that when I try to create a new user in some other DB like
> Pubs, Northwind etc. I am given 'BUILTIN\Administrators' as an option in the
> drop-down list of the login name. The authentication mode I am using is both
> SQL Server & Windows NT (I am working on Windows 2000 Professional).
> Thanks,
> Arpan
>|||Thanks, Bob, for your advice. You have hit the nail on the head in saying
that I might not have created a login for the database ForestDB. Thanks to
Tibor as well.
Regards,
Arpan
"Bob Simms" <bob_simms@.hotmail.com> wrote in message
news:4XCdb.408$_d.312@.news-binary.blueyonder.co.uk...
> It sounds as though you have not yet created a login. In Enterprise
Manager
> open up the Security container and right-click Logins. Create a new login
> called whatever you want. Assign him to those databases you want him to
> access. That will create both your login and database user.
> A login allows someone to be verified when they connect to SQL. It is an
> entry in the sysxlogins table in the Master db.
> A User is someone who already has a login in the sysxlogins table, but
> requires access to a specific database. They are placed in the sysusers
> table in the particular database they are trying to access.
> The Enterprise Manager dialog allows you to add a login and user at the
same
> time.
> HTH
> Bob
> --
> Warning: Do not look into the light sabre whilst switching it on
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003
>

Create a new database from a .bak backup

Hi, i have a problem:
I have a .bak file from a database backup, but i don't have the database
anymore.
How can i create the database from the backup file?
If i try to restore the database with management studio, i should already
have a database to put the data in.. but i don't have it anymore.
If i create a new database, and try to put the backed up data into it, i got
an error:
Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'XXX'
database.
Is there a way to re-create the database from the backup?(it's a full
backup)
I'm working with MSSQL Server 2005 and Management Studio.
Thank you for any advice!Hi
You don't need to start with a database when restoring. Click on the
database leaf in the tree and then enter your own database name in the
database name box, then go on and choose the file to restore from using the
restore from device option.
If you know that there is only one backup in the file and the database
doesn't exist you could use something like the following from a query window
if you change the file path/name and database name:
RESTORE DATABASE NewDatabase
FROM DISK = 'D:\Backups\DBBACKUP.bak'
GO
John
"GM" <guidomarche@.libero.it_n0sp4m> wrote in message
news:XbvAj.10735$q53.6897@.tornado.fastwebnet.it...
> Hi, i have a problem:
> I have a .bak file from a database backup, but i don't have the database
> anymore.
> How can i create the database from the backup file?
> If i try to restore the database with management studio, i should already
> have a database to put the data in.. but i don't have it anymore.
>
> If i create a new database, and try to put the backed up data into it, i
> got
> an error:
> Msg 3154, Level 16, State 4, Line 1
> The backup set holds a backup of a database other than the existing 'XXX'
> database.
>
> Is there a way to re-create the database from the backup?(it's a full
> backup)
> I'm working with MSSQL Server 2005 and Management Studio.
> Thank you for any advice!
>
>|||Hi, thank you for the answer!
the .bak file contains only one backup
If i use the restore option, and type a new database name, when i execute i
get te following error:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "D:\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf" failed with the operating system
error 3(The system cannot find the path specified.).
I've already tryed
RESTORE DATABASE NewDatabase
FROM DISK = 'D:\Backups\DBBACKUP.bak'
(with the right location/dbname)
but if the database does not exists, i got an error:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "D:\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf" failed with the operating system
error 3(The system cannot find the path specified.).
Msg 3156, Level 16, State 3, Line 1
File 'XXX_Data' cannot be restored to 'D:\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf'. Use WITH MOVE to identify a valid
location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "D:\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\XXX_Log.ldf" failed with the operating system
error 3(The system cannot find the path specified.).
Msg 3156, Level 16, State 3, Line 1
File 'XXX_Log' cannot be restored to 'D:\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\XXX_Log.ldf'. Use WITH MOVE to identify a valid
location for the file.
Msg 3119, Level 16, State 1, Line 1
I've tryed to use "WITH MOVE " tu point to another folder, but since i don't
have the mdf file, it's pointless...
If i create a new database with the same name of the database i want to
restor,e before trying to restore, i got the error i reported in the
previous post..
Any suggestion?
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:ePOUrASgIHA.5348@.TK2MSFTNGP03.phx.gbl...
> Hi
> You don't need to start with a database when restoring. Click on the
> database leaf in the tree and then enter your own database name in the
> database name box, then go on and choose the file to restore from using
> the restore from device option.
> If you know that there is only one backup in the file and the database
> doesn't exist you could use something like the following from a query
> window if you change the file path/name and database name:
> RESTORE DATABASE NewDatabase
> FROM DISK = 'D:\Backups\DBBACKUP.bak'
> GO
> John
> "GM" <guidomarche@.libero.it_n0sp4m> wrote in message
> news:XbvAj.10735$q53.6897@.tornado.fastwebnet.it...
>> Hi, i have a problem:
>> I have a .bak file from a database backup, but i don't have the database
>> anymore.
>> How can i create the database from the backup file?
>> If i try to restore the database with management studio, i should already
>> have a database to put the data in.. but i don't have it anymore.
>>
>> If i create a new database, and try to put the backed up data into it, i
>> got
>> an error:
>> Msg 3154, Level 16, State 4, Line 1
>> The backup set holds a backup of a database other than the existing 'XXX'
>> database.
>>
>> Is there a way to re-create the database from the backup?(it's a full
>> backup)
>> I'm working with MSSQL Server 2005 and Management Studio.
>> Thank you for any advice!
>>
>>
>|||"GM" <guidomarche@.libero.it_n0sp4m> wrote in message
news:7VxAj.10913$q53.947@.tornado.fastwebnet.it...
> Hi, thank you for the answer!
> the .bak file contains only one backup
> If i use the restore option, and type a new database name, when i execute
> i get te following error:
> Msg 5133, Level 16, State 1, Line 1
> Directory lookup for the file "D:\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf" failed with the operating system
> error 3(The system cannot find the path specified.).
>
> I've already tryed
> RESTORE DATABASE NewDatabase
> FROM DISK = 'D:\Backups\DBBACKUP.bak'
> (with the right location/dbname)
> but if the database does not exists, i got an error:
> Msg 5133, Level 16, State 1, Line 1
> Directory lookup for the file "D:\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf" failed with the operating system
> error 3(The system cannot find the path specified.).
> Msg 3156, Level 16, State 3, Line 1
> File 'XXX_Data' cannot be restored to 'D:\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\XXX_Data.mdf'. Use WITH MOVE to identify a valid
> location for the file.
> Msg 5133, Level 16, State 1, Line 1
> Directory lookup for the file "D:\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\XXX_Log.ldf" failed with the operating system
> error 3(The system cannot find the path specified.).
> Msg 3156, Level 16, State 3, Line 1
> File 'XXX_Log' cannot be restored to 'D:\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\XXX_Log.ldf'. Use WITH MOVE to identify a valid
> location for the file.
> Msg 3119, Level 16, State 1, Line 1
> I've tryed to use "WITH MOVE " tu point to another folder, but since i
> don't have the mdf file, it's pointless...
>
Umm, that's not pointless at all. That's the exact whay you do this.
RESTORE DATABASE NewDatabase
from disk='D:\Backups\DBBACKUP.bak'
with move 'XXX_Data' to 'C:\newlocation_fordata\XXX_LOG.MDF',
move 'XXX_log' to 'C:\newlocation_forlogs\XXX_LOG.LDF'
> If i create a new database with the same name of the database i want to
> restor,e before trying to restore, i got the error i reported in the
> previous post..|||RESTORE DATABASE [NewDatabaseName]
FROM DISK='BackupNameAndPath'
WITH MOVE 'OldDatabaseName' TO 'NewDatabaseNameAndPath.mdf',
MOVE 'OldDatabaseName_log' TO 'NewDatabaseNameAndPath.ldf'
NB the MOVEd strings are the logical database names. Use
RESTORE HEADERONLY FROM DISK = 'BackupNameAndPath'
to get a listing of the contents of the backup file to determine the
old database name.|||I forgot to say that i had to restore the database to a server different
from the one where i did the backup..
Anyway, with your help, i managed to recreate the database using:
RESTORE DATABASE XXX
FROM DISK = 'E:\bck\XXX.bak'
WITH
MOVE 'XXX_data' TO 'f:\sqldata\XXX_data.mdf'
, MOVE 'XXX_log' TO 'f:\sqldata\XXX_log.ldf'
, REPLACE;
thanks to all for your helpful suggestions!

Thursday, March 22, 2012

create a log file of a script

I'm am new to using SQL Server. In Oracle, when I create scripts to
manipulate data, I have a log file automatically created from within the
script by issuing the SPOOL command. Is there a similar functionality in SQL
server? besides the log file which records each transaction. Is there any
other way to run a script (automatically) besides cut & paste into SQL query
analyzer?
ThanksLee Ann,
The transaction log for the database is the only automatic record of the
transactions that I'm aware of. You could implement a custom solution using
a trigger/audit table or use a third-party log viewing tool. If you're
trying to test out the command prior to having it automatically commit
(admin type stuff) you can embed the code in a user-defined transaction
(BEGIN TRAN...COMMIT TRAN/ROLLBACK TRAN).

> Is there any other way to run a script (automatically)
You can use schedule a job: T-SQL, schedule a job - DTS, use OSQL and
Windows scheduler, auto-startup procs.
HTH
Jerry
"Lee Ann" <LeeAnn@.discussions.microsoft.com> wrote in message
news:1CA21C9E-3E8B-4265-B7A3-EBF26811AE94@.microsoft.com...
> I'm am new to using SQL Server. In Oracle, when I create scripts to
> manipulate data, I have a log file automatically created from within the
> script by issuing the SPOOL command. Is there a similar functionality in
> SQL
> server? besides the log file which records each transaction. Is there any
> other way to run a script (automatically) besides cut & paste into SQL
> query
> analyzer?
> Thanks|||Lee Ann,
One other approach would be to add auditing code (INSERTs and PRINTs) into
your original script.
HTH
Jerry
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:Ovq8PAqyFHA.1856@.TK2MSFTNGP12.phx.gbl...
> Lee Ann,
> The transaction log for the database is the only automatic record of the
> transactions that I'm aware of. You could implement a custom solution
> using a trigger/audit table or use a third-party log viewing tool. If
> you're trying to test out the command prior to having it automatically
> commit (admin type stuff) you can embed the code in a user-defined
> transaction (BEGIN TRAN...COMMIT TRAN/ROLLBACK TRAN).
>
> You can use schedule a job: T-SQL, schedule a job - DTS, use OSQL and
> Windows scheduler, auto-startup procs.
> HTH
> Jerry
> "Lee Ann" <LeeAnn@.discussions.microsoft.com> wrote in message
> news:1CA21C9E-3E8B-4265-B7A3-EBF26811AE94@.microsoft.com...
>|||Thanks Jerry...I will go and read up on your suggestions and then try it
out.
Lee Ann
"Jerry Spivey" wrote:

> Lee Ann,
> One other approach would be to add auditing code (INSERTs and PRINTs) into
> your original script.
> HTH
> Jerry
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:Ovq8PAqyFHA.1856@.TK2MSFTNGP12.phx.gbl...
>
>sql

create a local (portable) app plus data

We have an Access app that uses tables from an SQL server. Is it possible to
copy the SQL tables localy into the Access mdb file and run the app locally?
What about table relationships? How can I tell if they might be an issue?
Some relationships are built in the diagram tool on the server, and some are
coded into the app itself.
Thanks a heap - Randy
Randy,
Why don't you use MSDE (http://www.microsoft.com/sql/msde/default.mspx )
instead of Access? MDSE is SQL Server, desktop edition, and it is free. This
way you could have exactly the same structure in local databases as you have
on SQL Server.
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"RandyNesst" <RandyNesst@.discussions.microsoft.com> wrote in message
news:1382ED81-4064-4B05-956C-7DD5EF2D08FA@.microsoft.com...
> We have an Access app that uses tables from an SQL server. Is it possible
> to
> copy the SQL tables localy into the Access mdb file and run the app
> locally?
> What about table relationships? How can I tell if they might be an issue?
> Some relationships are built in the diagram tool on the server, and some
> are
> coded into the app itself.
> Thanks a heap - Randy
|||That sounds like a really good idea! I did a little looking around at the
link you gave me, but I have maybe a simple question - what is the process
like to create the MSDE localized database? Just an overview - is it about a
1 hour thing or about a 1 or more day thing? Is there a tool to do it?
Thanks again,
Randy
"Dejan Sarka" wrote:

> Randy,
> Why don't you use MSDE (http://www.microsoft.com/sql/msde/default.mspx )
> instead of Access? MDSE is SQL Server, desktop edition, and it is free. This
> way you could have exactly the same structure in local databases as you have
> on SQL Server.
> --
> Dejan Sarka, SQL Server MVP
> Mentor
> www.SolidQualityLearning.com
> "RandyNesst" <RandyNesst@.discussions.microsoft.com> wrote in message
> news:1382ED81-4064-4B05-956C-7DD5EF2D08FA@.microsoft.com...
>
>
|||Randy,
I am not quite sure whether I understand the question. If you mean the
process of creating a local copy of the server database, it is quite simple:
you can script all objects from the server db in Enterprise Manager and then
execute the script in Query Analyzer on the MSDE, and you have a local copy
with the same structure, but without data. if you need a copy of the data as
well, you can use Data Transformation Services, Merge Replication, ...
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"RandyNesst" <RandyNesst@.discussions.microsoft.com> wrote in message
news:62706E3A-F34B-4ABF-AA75-11600E920014@.microsoft.com...[vbcol=seagreen]
> That sounds like a really good idea! I did a little looking around at the
> link you gave me, but I have maybe a simple question - what is the process
> like to create the MSDE localized database? Just an overview - is it
> about a
> 1 hour thing or about a 1 or more day thing? Is there a tool to do it?
> Thanks again,
> Randy
> "Dejan Sarka" wrote:
|||At this point, you can download SQL Express 2005 (free also) and distro that
with your app.
William Stacey [MVP]
"RandyNesst" <RandyNesst@.discussions.microsoft.com> wrote in message
news:62706E3A-F34B-4ABF-AA75-11600E920014@.microsoft.com...[vbcol=seagreen]
> That sounds like a really good idea! I did a little looking around at the
> link you gave me, but I have maybe a simple question - what is the process
> like to create the MSDE localized database? Just an overview - is it
> about a
> 1 hour thing or about a 1 or more day thing? Is there a tool to do it?
> Thanks again,
> Randy
> "Dejan Sarka" wrote:

Create a hidden resource

Good day
I am using the CreateResource method (C#) to upload a jpg file to a report
server. I have completed this task, however I am manually navigating to the
Report Manager, going to the Properties section of the jpg file and checking
the "Hide in list view" checkbox.
I am sure this can be done programmatically, and I suspect it has to do with
this last parameter of the CreateResource method? Please could someone help
me.
ThanksI have managed to complete this, using the SetProperties method. The actual
property name I was looking for was "Hidden" - how simple :) I just set this
to "True"
"Imrahn" wrote:
> Good day
> I am using the CreateResource method (C#) to upload a jpg file to a report
> server. I have completed this task, however I am manually navigating to the
> Report Manager, going to the Properties section of the jpg file and checking
> the "Hide in list view" checkbox.
> I am sure this can be done programmatically, and I suspect it has to do with
> this last parameter of the CreateResource method? Please could someone help
> me.
> Thanks

create a flat file on a remote server

Hi,

In the new flat file connection dialog box, can i create a flat file on a remote server? thanks.

Yes, if you can access that server through a network share. Try using the UNC path, e.g.

\\ServerName\ShareName\Folder\File.txt

\\DGPC\C$\Temp\File.txt

sql