How to capture flat file timestamps in SSMS - sql-server

This is my first attempt to ask a question on this forum. I'm currently running a local instance of SQL2008 R2 on my machine. I have Googled many different ways to get this exact question answered but had no luck so far.
Simply put, I want to know how to capture a Windows flat file (foobar.txt) timestamp using t-sql code. I am totally new to MS SQL, and so far all I have run across is an undocumented sp called "xp_DirTree" which comes close but doesn't give me what I need. Is there a simple function that I'm overlooking here?

In SSIS there is a Logging feature. Create a new connection for Logging and link to the SQL Server database. You can select what features should be stored in the new table. The new table created will be named as "sysssislog" inside System Tables.

Related

VB.NET Application using SQL or Local DB

I'm working on an application and am trying to offer the ability to use a "Local" database or a SQL Server database. What I'm trying to work out is the best Local DB format to use and how to write the queries.
At the moment i have been playing with SQL Server CE and it seems to work fine, but I then need to write each code block twice for any queries (once for SQL and once for SQL Server CE). Is there any solutions to this? Is there some way i can just pass a different connection string?
What i have at the moment is a "sub" that i have a check if using local (my.setting.uselocal) and then call either function Query_SQL or Query SQL. I imagine it will get tiring soon to have to have two blocks for each database query?
Any suggestions on how to do this more efficiently?
Cheers
You could try creating a .sdf file. These can be created programmatically, along with a databse(s)/tables etc in the file.
It's been a long time since I've used them but IIRC you can write read/write with the same tsql syntax. I would have thought it would allow you the same query functions and you can then pass in whatever connection.

Accessing Information from a SQL Dataset

I have recently started working with SQL databases of which I have no previous experience with. I have added the datasource to my project using the Visual Studio wizard and the DataSet appears in my solution explorer.
Everything that I have read thus far has shown connecting to the SQL server and then sending query commands, but since I have added the direct reference to my project is this necessary. I thought since I had added the reference to my project I would have direct accesbility to it, but it appears that is not so.
Also to help the searching process a view has been created on the SQL server that polls all of my desired fields in a single shot. I have linked this view to my dataset after utilized the datasource wizard. Any recommendations on how I can access the data from that view?
I apologize for the vagueness of my questions, but I am not really 100% sure the questions I need to be asking. I appreciate the help.
Thanks
Turns out the best means to solve this problem was to ditch the Data Source Wizard and use standard SQL queries.

XML : save data from sql server to file

I'd like to save data from a SQL Server database table to a file, then load it into another database that has the same table already created in it
How can I do this? I know there should be some simple way of doing it, but stackoverflowsearch and google aren't yielding good answers (or I'm not asking a good question).
SQL Server Import and Export Wizard
It's located under the SQL Server startup menu folder.
As far as I know there is no simple way to do this in SQL only.
Probably best way to handle this is to create your own simple application in whatever programming language that will query first database, write the file where it needs to be written and also import data into another database.

Can I dump an entire Microsoft SQL Server database from Linux?

I've got a linux server that already connects happily to a MS SQL Server and I want to know if there is a way to dump the whole thing into a format I can read. I don't have access to the desktop, but I can connect using PHP and I can issue whatever commands I want. I have admin access to the SQL Server, so no problem there.
My main goal is to understand how the people before me set this thing up. I already know how to get the stored procedures as text (SELECT * FROM sys.procedures), but I was wondering if there is a way to get the whole database. I'm not very familiar with SQL Server so I don't know what important bits I might be missing.
And I don't care if the solution is in PHP or not. That's just the thing I've got working right now. Any SQL-ish command that dumps the entire database would solve my world.
To summarize:
I don't have access to the actual machine/desktop
I have admin access to the DB using PHP's mssql libs
I'm on linux
I want a text file I can look at that tells me everything in the database
My goal is not to answer a specific question - I'm looking to understand what the people before me did when they set up this database. Unknown unknowns, and all that.
Okay, hopefully I've made sense. I'm sorry if I've been a complete idiot. Be gentle. Thanks!
I would backup (http://msdn.microsoft.com/en-us/library/ms186865.aspx) the database to file and then download it, restore it on Windows and then use SQL Server tools like SQL Server Management Studio etc. to look at it.
There is plenty you can do with the metadata, but you could spend a lot of time writing queries instead of using existing off-the-shelf documentation tools.
You can use this script to create insert statements for any given table.
This stackoverflow question will tell you how to generate create table statements.
SELECT NAME FROM sys.tables will give you a list of table names.
You would probably save a LOT of time and pain by just using native SQL SErver Windows tools that work with it.

Syncing Data between MS SQL Server and Oracle Server

My colleague and I are trying to find the best query to sync up an Oracle database with that of a SQL server. There are about 80k+ rows with ~19 columns of data in each row. We have a linked server setup between the two servers and we have a query that works but for 80k records, the query took 10 hours to copy the records over. I can post the query we used but I would like to have a fresh set of eyes. This is a new process so we aren't trying to retrofit a solution to existing code. LIke I said before, permissions aren't an issue, it is just a matter of getting the data from Point A to Point B in the quickest time. This is to be used on a coldfusion supported web site and the client would like to click a buttton to sync up the data but again, this is just "wish list" of requirements we are working with.
Additional Thoughs I'd like to add:
We have tried openquery and using linked server but both took about the same time to complete.
Most are varchar(64 bytes), a couple of varchar(128) and a couple of varchar(12 bytes).
One suggestion someone else made was to write the data to a flat file, ftp the flat file to Point B and then import it. That is a viable solution but the more steps we include, the more chances there are of something breaking.
Thanks in advance. I look forward to seeing y'alls solutions.
I've had more success with an SSIS package than linked servers. If you use the Oracle DLL's, it's not too bad.
Have you looked at Oracle Transparent Gateway? Here is the reference manual. It drives SQL Server from Oracle instead of the other way around.
Zidsoft CompareData you can set up the sync task visually and also scheduling it to run via the commandline. Disclosure: I am the developer of this product.

Resources