Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Thursday, March 29, 2012

Get a SQL Backup Folder Path in asp.net

Hi

Anyone knows , get a SQL Backup Folder Path in asp.net.Some Systems it displayed like D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup and some Systems like E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup and etc. i need to get a path for backup programmatically.Please help me.

Tamil

You can back up the databse to any location you'd like. You specify the path when you back up the DB.

sql

Tuesday, March 27, 2012

Get a list of files a SQL Server instance can access

I'd like to be able to present my user with a tree view of the devices and
directories a remote SQL Server machine can access.
What I need to do is what Enterprise Manager can do: if I connect to a SQL
Server database on a remote machine to do a backup, when I come to select a
filename the browse button shows me a view of devices and directories on the
remote machine.
Is this a private trick reserved to EM or is there a way to do it with
SQL-DMO?
Thanks in advance for any help
GrahamAt the TSQL level, EM uses some extended stored procedures. Run Profiler and
see what they are. Not
documented, use at own risk etc.
I'm not sure whether these procedures are available through DMO, though. It
would be great to have a
DMO trace tool, btw. A quick check in BOL didn't show anything obvious. The
closest I could come is
the EnumDirectories method, perhaps worth using as a starting point?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Graham Morris" <Graywing@.newsgroup.nospam> wrote in message
news:eVG$wvUCFHA.3976@.tk2msftngp13.phx.gbl...
> I'd like to be able to present my user with a tree view of the devices and
directories a remote
> SQL Server machine can access.
> What I need to do is what Enterprise Manager can do: if I connect to a SQ
L Server database on a
> remote machine to do a backup, when I come to select a filename the browse
button shows me a view
> of devices and directories on the remote machine.
> Is this a private trick reserved to EM or is there a way to do it with SQL
-DMO?
> Thanks in advance for any help
> --
> Graham
>|||Graham Morris wrote:
> I'd like to be able to present my user with a tree view of the
> devices and directories a remote SQL Server machine can access.
> What I need to do is what Enterprise Manager can do: if I connect to
> a SQL Server database on a remote machine to do a backup, when I come
> to select a filename the browse button shows me a view of devices and
> directories on the remote machine.
> Is this a private trick reserved to EM or is there a way to do it with
> SQL-DMO?
> Thanks in advance for any help
> --
> Graham
-- To query available drives
Execute master..xp_availablemedia 2
-- To query directories
Execute master..xp_subdirs N'C:'
David Gugick
Imceda Software
www.imceda.com|||Thanks - just what I need.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:uIERzKWCFHA.904@.TK2MSFTNGP12.phx.gbl...
> Graham Morris wrote:
> -- To query available drives
> Execute master..xp_availablemedia 2
> -- To query directories
> Execute master..xp_subdirs N'C:'
> --
> David Gugick
> Imceda Software
> www.imceda.com

Get a list of files a SQL Server instance can access

I'd like to be able to present my user with a tree view of the devices and
directories a remote SQL Server machine can access.
What I need to do is what Enterprise Manager can do: if I connect to a SQL
Server database on a remote machine to do a backup, when I come to select a
filename the browse button shows me a view of devices and directories on the
remote machine.
Is this a private trick reserved to EM or is there a way to do it with
SQL-DMO?
Thanks in advance for any help
Graham
At the TSQL level, EM uses some extended stored procedures. Run Profiler and see what they are. Not
documented, use at own risk etc.
I'm not sure whether these procedures are available through DMO, though. It would be great to have a
DMO trace tool, btw. A quick check in BOL didn't show anything obvious. The closest I could come is
the EnumDirectories method, perhaps worth using as a starting point?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Graham Morris" <Graywing@.newsgroup.nospam> wrote in message
news:eVG$wvUCFHA.3976@.tk2msftngp13.phx.gbl...
> I'd like to be able to present my user with a tree view of the devices and directories a remote
> SQL Server machine can access.
> What I need to do is what Enterprise Manager can do: if I connect to a SQL Server database on a
> remote machine to do a backup, when I come to select a filename the browse button shows me a view
> of devices and directories on the remote machine.
> Is this a private trick reserved to EM or is there a way to do it with SQL-DMO?
> Thanks in advance for any help
> --
> Graham
>
|||Graham Morris wrote:
> I'd like to be able to present my user with a tree view of the
> devices and directories a remote SQL Server machine can access.
> What I need to do is what Enterprise Manager can do: if I connect to
> a SQL Server database on a remote machine to do a backup, when I come
> to select a filename the browse button shows me a view of devices and
> directories on the remote machine.
> Is this a private trick reserved to EM or is there a way to do it with
> SQL-DMO?
> Thanks in advance for any help
> --
> Graham
-- To query available drives
Execute master..xp_availablemedia 2
-- To query directories
Execute master..xp_subdirs N'C:\'
David Gugick
Imceda Software
www.imceda.com
|||Thanks - just what I need.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:uIERzKWCFHA.904@.TK2MSFTNGP12.phx.gbl...
> Graham Morris wrote:
> -- To query available drives
> Execute master..xp_availablemedia 2
> -- To query directories
> Execute master..xp_subdirs N'C:\'
> --
> David Gugick
> Imceda Software
> www.imceda.com
sql

Wednesday, March 21, 2012

Generating script per object

Hi,
I want to generate Script for 4 Stored Procedures at a time in SQL SERVER 2005 as 4 seperate files.

In SQL SERVER 2000 there is a option
-Script file per object, using which we can generate script only once for all the 4 sps as 4 seperate files
Is there any such option in 2005?

Please suggest.

Thanks in advance

Ram

They added this feature to the Scripting Wizard in SP2.|||

Jason Callas wrote:

They added this feature to the Scripting Wizard in SP2.

To elaborate a little bit more... if you use the Generate Script Wizard in SQL Server 2005 SP2, you can choose to create one file per object.

Steps:

1) Right-click on a database -> Tasks -> Generate Scripts...

2) On the "Output Option" screen

a) Choose "Script to file"

b) Choose "File per object"

Paul A. Mestemaker II

Program Manager

Microsoft SQL Server Manageability

http://blogs.msdn.com/sqlrem/

sql

Generating reports from flat files

Hi

I got two text files with data.I got to compare two files and if there is any inconsistancy between two files I need to dispaly as a report using sql reporting services.I do not know how to do that?

Any source code or suggestion.

Thanx in advance

What is the format of the data files? By "comparing", is this line-for-line, character-for-character, or is the structure of the files regular data rows?

>L<

|||line-for-line|||

Different people will give you different advice about the best thing to do here, depending on which environment they are comfortable working in. All the different types of advice will boil down to the following steps:

consume both files into the same structure, which has one row for each row of the file(s).

It doesn't matter whether this is an XML structure or a database table, or how the data gets into that structure, that is a detail of implementation we can discuss when you tell us more about your background. You could use an SSIS package, read the files in CLR code a line at a time, etc.

Here are some thoughts about exactly what you should store:
I think it would be useful to have an integer value representing line number in this case as well, for reporting purposes.
Make some determinations about what represents a significant change between the files. This will make some differences in how you store the rows. For example: do you omit "whitespace" lines -- can they be safely skipped? Suppose that (for instance) the two files are identical but row 80 has an extra carriage return in one file. Does that mean that all the rows from 81 down are counted as different from each other, working on line number basis only? Or are they the same, even though the line numbers are offset by 1? is punctuation significant? Is case-sensitivity?
|||

Thanx for you advice.

I have done like this but how will you give the xml structure generated from flat files to the reporting engine.

Any idea

Thanx

|||

You can use the XML files as a datasource directly, if you design the XML to look like ADO dataset XML.

You can also have a "real" database consume the XML (regardless of its schema) and then do the report from there.

What does your XML look like?

>L<

Monday, March 19, 2012

Generating Custom Messages to User

Hello everyone,

i'm using a foreach loop container to read a group of excel files and pass their information to a Sql Server database. The process runs well but sometimes there could be some excel files that may not be processed correctly so i'm using transacctions to continue to process on the other files, But i'd like to generate a message everytime an excel file is or not processed. I thought that i could generate a flat file to do it, but is there any other way to accomplish this? I'm also generating a log file (on xml format), but It seems too much information for an end-user.

any suggestions?

regards.

You can generate messages that automatically get captured by your log provider. Is this what you want to do?

-Jamie

|||Hello Jamie

I'm actually using a log provider, so i get the log of the progress.

My solution was to get into the log (which is an xml output file) two kind of messages: the first one, an script that Logs a new "Sucess file" message and another script task which says "Failure process file". So at the end of the tasks i need to run, i get just one of the script tasks to log into my file.

But is there any other way to do it?.

regards

Monday, March 12, 2012

Generate XSD from XML

Hi,

I'm new to SQL2005 and even newer to .XML. I've been using SSIS to bring in some .XML files using the XML datasource in SSIS. I use the "generate XSD" button to read the XML file and build the XSD for me. This works great but it seems that the "generate" button always ends up normalizing out every table attribute into seperate tables, even 1:1 attributes. A 3 table schema with 10 attributes per table ends up coming in as a 30 table schema. In my case it ended up as a 104 table schema. Not knowing a whole lot about .XML I'm wondering if there are tools out there that can be used to gen an XSD off of an XML file but do it in a smarter manner such as keeping all the 1:1 attribute in a single table? I Googled that and found no utilities like that.

Any help is appreciated.

G

After a week I can answer my own question. Inside of Visual Studio there is a utility to generate "intelligent" XSD files. It took my 104 table schema and boiled it down to 3 tables.|||

Hello PM2k - we have a similar need. Could you please point out how to locate the utility you mentioned in Visual Studio that generates the "intelligent" xsd? Any additional background / info you can provide would be most appreciated!

Thanks.

Generate XSD from XML

Hi,

I'm new to SQL2005 and even newer to .XML. I've been using SSIS to bring in some .XML files using the XML datasource in SSIS. I use the "generate XSD" button to read the XML file and build the XSD for me. This works great but it seems that the "generate" button always ends up normalizing out every table attribute into seperate tables, even 1:1 attributes. A 3 table schema with 10 attributes per table ends up coming in as a 30 table schema. In my case it ended up as a 104 table schema. Not knowing a whole lot about .XML I'm wondering if there are tools out there that can be used to gen an XSD off of an XML file but do it in a smarter manner such as keeping all the 1:1 attribute in a single table? I Googled that and found no utilities like that.

Any help is appreciated.

G

After a week I can answer my own question. Inside of Visual Studio there is a utility to generate "intelligent" XSD files. It took my 104 table schema and boiled it down to 3 tables.|||

Hello PM2k - we have a similar need. Could you please point out how to locate the utility you mentioned in Visual Studio that generates the "intelligent" xsd? Any additional background / info you can provide would be most appreciated!

Thanks.

Generate XSD from XML

Hi,

I'm new to SQL2005 and even newer to .XML. I've been using SSIS to bring in some .XML files using the XML datasource in SSIS. I use the "generate XSD" button to read the XML file and build the XSD for me. This works great but it seems that the "generate" button always ends up normalizing out every table attribute into seperate tables, even 1:1 attributes. A 3 table schema with 10 attributes per table ends up coming in as a 30 table schema. In my case it ended up as a 104 table schema. Not knowing a whole lot about .XML I'm wondering if there are tools out there that can be used to gen an XSD off of an XML file but do it in a smarter manner such as keeping all the 1:1 attribute in a single table? I Googled that and found no utilities like that.

Any help is appreciated.

G

After a week I can answer my own question. Inside of Visual Studio there is a utility to generate "intelligent" XSD files. It took my 104 table schema and boiled it down to 3 tables.|||

Hello PM2k - we have a similar need. Could you please point out how to locate the utility you mentioned in Visual Studio that generates the "intelligent" xsd? Any additional background / info you can provide would be most appreciated!

Thanks.

Friday, February 24, 2012

generate file task with 2 files

Hi Guys,

I've one Dafta flow task where I'm getting data from OleDb source and then doing some scripting using script component and then generating a file.

Now I would need to get the same data and apply some different things and generate another file.
Can I used this same task for doing the secondry work? If yes how woulld I put the thing in place, I would need to get the same data but I would need to use a seperate scripting and generate a seperate file?

TA

Gemma

You can use a multicast transformation to split your dataflow up into two or more flows. If you add a multicast right after your OLE DB source, you can then move your data to two script components each connected to their own file destination.

OLESRC
|
MC
/ \
S S
/ \
FD FD

Generate BCP data file with money columns using C#?

I need to use C# to generate the data files for BCP. Which C# data type I
should use to generate the data columns for SQL money money?
' money;
FileStream fs = new FileStream("test.txt", FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
....
bw.Write(money);
....
bw.Close();
fs.Close();nick (nick@.discussions.microsoft.com) writes:
> I need to use C# to generate the data files for BCP. Which C# data type I
> should use to generate the data columns for SQL money money?
> ' money;
> FileStream fs = new FileStream("test.txt", >
FileMode.CreateNew);
> BinaryWriter bw = new BinaryWriter(fs);
> .....
> bw.Write(money);
> .....
> bw.Close();
> fs.Close();
That depends on how you intend to run BCP. BCP can handle both text
formats and binary formats.
But assuming that you intend to use text file - that is after all the
most common - you should write the value as in -1212.2345. That is, you
should not use any currency character or thousands separator, and you should
force the decimal delimiter to be point, and not let regional settings
affect the output.
As for which data type you should use in C#, this may not be the best
newsgroup to ask in. Again, it depends on your exact needs, but you
probably should use an exact data type, that is not double.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||How about binary format? I think it may use less space and thus faster for
very big file? I know float works but it may not be good for money type...
"Erland Sommarskog" wrote:

> nick (nick@.discussions.microsoft.com) writes:
> FileMode.CreateNew);
> That depends on how you intend to run BCP. BCP can handle both text
> formats and binary formats.
> But assuming that you intend to use text file - that is after all the
> most common - you should write the value as in -1212.2345. That is, you
> should not use any currency character or thousands separator, and you shou
ld
> force the decimal delimiter to be point, and not let regional settings
> affect the output.
> As for which data type you should use in C#, this may not be the best
> newsgroup to ask in. Again, it depends on your exact needs, but you
> probably should use an exact data type, that is not double.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>|||nick (nick@.discussions.microsoft.com) writes:
> How about binary format? I think it may use less space and thus faster
> for very big file? I know float works but it may not be good for money
> type...
But binary format is more difficult to work with, as these are essentially
the native formats of SQL Server. Maybe money is a simple as a 64-bit
integer value with an implied decimal point. That's the type used in the
OLE DB interface, but whether that actually represents the actual storage
in SQL Server I don't know.
Of course, you compose an example table, and then bulk out that data in
native format and study it in a hex editor.
I strongly recommend that you start with a text file. If you really
need to trim performance later on, then you could look into to using
a binary format.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Sunday, February 19, 2012

Generate .sql ?

Hi!

When MS published starter kits there were files .sql in App_Data. This files contained some sample data for a DB. How to create such files when I have database with data ?

Jarod

The quick answer is you can't and the reason is when there is data you need to Backup and Restore because it moves everything including permissions and data in the database, the other option is to Detach and Attach with code, the last option use DTS/SSIS to move the database because it is a data transfer and cleaning tool. I have a faq of all the methods to move a database, post again if you still have question. Hope this helps.

http://forums.asp.net/thread/1454694.aspx

|||I agree with Caddre. For database objects, you can only generate DDL statements for them. There is no way to generate .sql for data.

Generate .chm files from Stored Procedure Comments

Hi everyone,

I need to create a .chm file from the Comments given in Stored Procedure.My Stored Procedure looks like this :

This is the Header Block of Stored Procedure :

/*
Name :s_Get_Audit
Author :sidheshwar Description : This stored procedure will return rows for Function Report
Notes :
Date : 08 Nov 2006
Input parameterSleep :
@.LocID
@.DeptID
@.DeptMgrID
@.UnitMgrID
@.RACFID
@.From_Date
@.To_Date

VariableSleep : None
Output parameterSleep : None
Usage : EXEC s_Get_Audit
@.LocID = 0,
@.DeptID = 0,
@.DeptMgrID = 0,
@.UnitMgrID = 0,
@.RACFID = 0,
@.From_Date = '12/05/2006',
@.To_Date = '12/06/2008'
DTS
History
MM/DD/YYYY Developer Change/Comment
-
11/08/2006 Sidheshwar N Created
--*/

I need to write C# Application to generate .cmh from the above Stored Procedure

In short i m creating a Database Objects Manual.

Thanks in Advance

Sidheshwar.

In SQL Server we only use CHM files for the F1 topics. Books Online uses a new help product called dexplorer. The HTML Help SDK you're looking for is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vsconHH1Start.asp