Monday, March 26, 2012
importing sql2005 database diagram to word doc
relationships. When I copy the diagram to the clipboard and paste it to a
word doc the diagram is hard to read because the letering on each table
appears quite small. I tried changing the zoom within management studio
prior to the copy but it has no effect. Any ideas or is there a specific
method of exporting the image other than just copy to clipboard and paste?
thanks.
--
Paul G
Software engineer.If you take a big diagram and squeeze it into a small space, I don't
know how to avoid the text getting small. I know that when I wanted
to print a diagram to a single page the approach I took was to expand
it to 200%, copy it, then past it into Irfanview and print from there.
I could also save it from there as a jpeg. I suppose you could try
that, and then see if placing the jpeg into the Word document works
any better, but I would not hold out much hope.
Roy Harvey
Beacon Falls, CT
On Fri, 25 Apr 2008 09:46:00 -0700, Paul
<Paul@.discussions.microsoft.com> wrote:
>Hi I have a large database diagram and am only displaying the table names and
>relationships. When I copy the diagram to the clipboard and paste it to a
>word doc the diagram is hard to read because the letering on each table
>appears quite small. I tried changing the zoom within management studio
>prior to the copy but it has no effect. Any ideas or is there a specific
>method of exporting the image other than just copy to clipboard and paste?
>thanks.|||thanks for the information. I ended up just using the table names to gain
some space and was able to move the objects around (closer together) within
SQL Server Management Studio. Have not heard of Irfenview, might have to
check it out.!
--
Paul G
Software engineer.
"Roy Harvey (SQL Server MVP)" wrote:
> If you take a big diagram and squeeze it into a small space, I don't
> know how to avoid the text getting small. I know that when I wanted
> to print a diagram to a single page the approach I took was to expand
> it to 200%, copy it, then past it into Irfanview and print from there.
> I could also save it from there as a jpeg. I suppose you could try
> that, and then see if placing the jpeg into the Word document works
> any better, but I would not hold out much hope.
> Roy Harvey
> Beacon Falls, CT
> On Fri, 25 Apr 2008 09:46:00 -0700, Paul
> <Paul@.discussions.microsoft.com> wrote:
> >Hi I have a large database diagram and am only displaying the table names and
> >relationships. When I copy the diagram to the clipboard and paste it to a
> >word doc the diagram is hard to read because the letering on each table
> >appears quite small. I tried changing the zoom within management studio
> >prior to the copy but it has no effect. Any ideas or is there a specific
> >method of exporting the image other than just copy to clipboard and paste?
> >thanks.
>|||On Fri, 25 Apr 2008 14:00:00 -0700, Paul
<Paul@.discussions.microsoft.com> wrote:
>Have not heard of Irfenview, might have to
>check it out.!
Irfanview is a free utility for viewing image files, but it also has
some manipulation ability such as changing resolution. A great
utility, but nothing unique.
Roy Harvey
Beacon Falls, CT
Friday, March 23, 2012
Importing multiple Excel files.
files. All the Excel files are in one folder and have the same column names.
What is the best way to get them into a table in the database? While
looping though the folder can you just do a bulk insert on the excel files?"Don" <Don@.discussions.microsoft.com> wrote in message
news:510DB3BC-CAFD-42BC-8262-9D43B577A82D@.microsoft.com...
> Hello, I have a SQL Server 2000 database that I want to load with Excel
> files. All the Excel files are in one folder and have the same column
> names.
> What is the best way to get them into a table in the database? While
> looping though the folder can you just do a bulk insert on the excel
> files?
Use DTS. The following example uses a text file but it could equally be
Excel:
http://www.sqldts.com/default.aspx?246
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--sql
Monday, March 19, 2012
Importing files with unknown names
After it is imported, I want to look at the NAME of the file, and pull out the date portion of it. So, if the file is called SO122603.TRN, i want to pull out 122603, and then update my table with that date for every record. So when I am done, I will have a table that represents the file I imported, with one added column. This added column would be a Date/Time that has the date that was in the filename. How do I do this?I should add though - that this file that I want to import will be in a directory BY ITSELF. (There will be no other files in that folder). Is there a way to look in a directory, see what file is there, import it, and then parse the filename so I can get the date?|||as a matter of fact...just finished building that..
Select @.Command_String = 'Dir ' + @.FilePath + '\*.*'
Insert Into XLAT_Folder exec master..xp_cmdshell
PRINT 'DISPLAY XLAT_Folder'
SELECT * FROM XLAT_Folder
Delete From XLAT_Folder_Parsed
PRINT 'PARSE FOLDER'
Insert Into XLAT_Folder_Parsed (Create_Time, File_Size, [File_Name] )
Select Convert(datetime,Substring(dir_output,1,8)
+ ' '
+ (Substring(dir_output,11,5)
+ Case When Substring(dir_output,16,1) = 'a' Then ' AM' Else ' PM' End)) As Create_Time
, Convert(Int,LTrim(RTrim(Replace(Substring(dir_outp ut,17,22),',','')))) As File_Size
, Substring(dir_output,40,(Len(dir_output)-39)) As [File_Name]
From XLAT_Folder
Where Substring(dir_output,1,1) <> ' '
And (Substring(dir_output,1,1) <> ' '
And Substring(dir_output,25,5) <> '<DIR>')
AND Substring(dir_output,40,(Len(dir_output)-39)) LIKE 'XLAT%'|||How bout adding and an Active X script Task that gets the file name and sets a global variable in the DTS package. Somewhere in the script just parse out the date or whatever.
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Function Main()
Dim objFSO
Dim objFolder
Dim objFile
Dim oPKG
Dim fileName
Dim filePath
Dim oConnectionSource
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("\\server\data$\")
For Each objFile in objFolder.Files
filePath = objFile.Path
fileName = objFSO.GetFileName(objFile.Path)
Set oPKG = DTSGlobalVariables.Parent
oPKG.GlobalVariables("fileName").Value = (filePath & fileName)
Set oConnectionSource = oPKG.Connections("Text File(Source)")
oConnectionSource.DataSource = (filePath & fileName)
Set oConnectionSource = Nothing
Set oPKG = Nothing
Next
Main = DTSTaskExecResult_Success
End Function|||I prefer using the fso object since xp_cmdshell presents problems.|||Yup|||Originally posted by rnealejr
I prefer using the fso object since xp_cmdshell presents problems.
Like what?|||Memory Leaks|||Originally posted by SHICKS
Memory Leaks
In stored procedures?|||Most production sql servers drop xp_cmdshell because of security risks.|||http://www.databasejournal.com/features/mssql/article.php/1580041
This does not address memory leaks, but address issues of SP3 and XP_CMDSHELL.|||Originally posted by SHICKS
Memory Leaks
Seems to be the other way around...
Wednesday, March 7, 2012
Importing Data from Excel to update existing fields
I think I've figured out how to use DTS and update the two fields, but I'm afraid that when everything runs new entries will be created with component information. Is it possible to specify that only rows where Pf_ID matches some row in column A that same row's column B will be used to update the data in In_Stock. I may have just made things too confusing than they need to be, but I don't have much experience with EM or Excel.
I'm also considering trying to write a macro that will match Pf_IDs in an exported excel file of the products table and take rows out of the excel file with current quantity information putting them in a new excel file to import into the website's database.
Please help, this is getting really confusing.I would bcp the data into a staging table, then use sql to do whatever you have to do.
But that's just me
MOO|||I'm not sure what bcp stands for ... I've only seen dts. I think your idea of using a staging table to query data from sounds good, but I kind of want this to be as simple a process as possible. Something that relatively anyone with instructions could click buttons and have done routinely.|||use dts to bring the excel data into a staging table
(a table created just to store data in the middle of a coomplex import)
then use an update statement against the staged data to update the destination data
(use the transact sql task)
For a more straightforward (but more advanced) method you might consider using the data driven query task and you could eliminate the staging table.
once you get this running you can set it up as a batch file or script or even call it from a sp. so anyone can run it.|||I've called tech support and checked permissions on the product table, but niether of us can seem to get this query to work when importing data from an excel workbook, Peach$. Is there something wrong with my query?
Here's what the support said when he tried:
It doesnt appear to be working running as SA either. I get a Error Line 3 near ) and then the db is read-only.
I cleared active connections to the DB and even stopped access, but it still appears to be locked by something, or perhaps the table is protected somehow?
--Raj
Here is the actual query:
update ASI.dbo.Product
set ASI.dbo.Product.In_Stock = (select `Peach$`.`Quantity On Hand`
from `Peach$`
where ASI.dbo.Product.Pf_ID = `Peach$`.`Item ID`)
where exists
(select `Peach$`.`Quantity On Hand`
from `Peach$`
where ASI.dbo.Product.Pf_ID = `Peach$`.`Item ID`);
Sorry for the lag time with a reply. I hope this gets read now.
Importing data & inserting value
1. Drop & recreate a temp table with an additional column as a default value based on the corresponding file extension (manually entered into the DTS routine).
2. Import a single file into a temp table.
3. Transfer the temp table data to the permanent table with Keep Null Values ticked.
Ive only got as far as importing 2 of the files (which works!) but is getting messy already with 10 steps so far!
There must be an easy way as a file is being imported to add a value on each row rather then going through all these processes!
Can anyone help?
Thanks in advance!You can use the bcp import utility with a format file. See in BOL for more info on format files.
Sunday, February 19, 2012
Importing Access databases into SQL Server
I have a situation where an application needs to import data from
number of access mdb files on a daily bases. The file names change
every day. The data import is very straight forward:
insert into sql_table select * from acess_table
There are up to 8 tables in each access file and some access files will
have less. So the process needs to figure out which tables exist in
Access mdb file and import them whole into sql staging tables.
Any recommendations are appreciated.
ThanksIt probably depends where you're running the load process from - that's
not really clear (to me) from your comments. If you push the data from
Access, then presumably it's not a problem, because you know which
tables are in each database. If you need to pull from MSSQL, and the
Access database names are always the same, then you could create linked
servers to each one, and get the data that way.
If the Access database names change, and you don't know in advance how
many tables there will be in each one, then you'll need something more
flexible. Personally, I would probably use DTS to connect to each
database, query the metadata to get the table names (although I don't
know exactly how to do that - perhaps an Access group could give more
details), and then load the data dynamically. Or write a tool in Perl,
C# or whatever to dynamically export and import the data via flat files
or ADO.
Finally, one other option would be to convert your Access databases to
ADPs, so you would have the data in MSSQL already. But this may not be
possible or desirable in your situation.
If this doesn't help, I suggest you post some more specific details of
what you need to do.
Simon|||How are these Access files being created daily
with different names and more importantly why?
What kind of bizarre methodology would require
different-named Access files on a daily basis?
GeoSynch
<boblotz2001@.yahoo.com> wrote in message
news:1112217371.433176.279470@.f14g2000cwb.googlegr oups.com...
> Hi there,
> I have a situation where an application needs to import data from
> number of access mdb files on a daily bases. The file names change
> every day. The data import is very straight forward:
> insert into sql_table select * from acess_table
> There are up to 8 tables in each access file and some access files will
> have less. So the process needs to figure out which tables exist in
> Access mdb file and import them whole into sql staging tables.
> Any recommendations are appreciated.
> Thanks