Showing posts with label excel. Show all posts
Showing posts with label excel. Show all posts

Monday, March 19, 2012

Creating sql server table from dts

I am trying to design a SSIS DTS package that imports an Excel named range (acts as a table) into a SQL Server 2005 database table. The direct import (using the import/export wizard) works fine, but I need to use a DTS package with a data transformation step. The DTS fails to create/replace/or update the SQL Server table. Suggestions?

Which is it? SSIS or DTS?

Can you clarify what you're trying to do?

How are you attempting to create/replace/update the table?

Kirk Haselden
Author "SQL Server Integration Services"

|||

Kirk, Thank you for the response. Your book will arrive tomorrow and I expect it to answer my many questions. I am trying to use the SQL Server 2005 SSIS designer to produce a package (SSIS or DTS?) to copy a named range (proxy for an Excel 'table') from a network drive; convert the data types to what I want on the SQL Server 2005 server; delete the database table if it already exists and create a new table; and write the new data to the table. The connection to the Excel workbook named range and the data conversion step work fine. I get the following error in the destination step: [SQL Server Destination [98]] Error: An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Could not bulk load because SSIS file mapping object 'Global\DTSQLIMPORT ' could not be opened. Operating system error code 2(The system cannot find the file specified.). Make sure you are accessing a local server via Windows security." I have no idea what this means!

I am a 'user' rather than an 'IT pro' who is trying to build a small 'data-mart' for better management of data used for analysis, forecasting and strategic planning. A SSIS package appears to be the best means for accomplishing this task every month and many other data upload packages will be produced as soon as I understand the process.

Thank you for your help.

|||Kirk Haselden's book on Integration Services is very helpful. I highly recommend it!

Creating sql server table from dts

I am trying to design a SSIS DTS package that imports an Excel named range (acts as a table) into a SQL Server 2005 database table. The direct import (using the import/export wizard) works fine, but I need to use a DTS package with a data transformation step. The DTS fails to create/replace/or update the SQL Server table. Suggestions?

Which is it? SSIS or DTS?

Can you clarify what you're trying to do?

How are you attempting to create/replace/update the table?

Kirk Haselden
Author "SQL Server Integration Services"

|||

Kirk, Thank you for the response. Your book will arrive tomorrow and I expect it to answer my many questions. I am trying to use the SQL Server 2005 SSIS designer to produce a package (SSIS or DTS?) to copy a named range (proxy for an Excel 'table') from a network drive; convert the data types to what I want on the SQL Server 2005 server; delete the database table if it already exists and create a new table; and write the new data to the table. The connection to the Excel workbook named range and the data conversion step work fine. I get the following error in the destination step: [SQL Server Destination [98]] Error: An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Could not bulk load because SSIS file mapping object 'Global\DTSQLIMPORT ' could not be opened. Operating system error code 2(The system cannot find the file specified.). Make sure you are accessing a local server via Windows security." I have no idea what this means!

I am a 'user' rather than an 'IT pro' who is trying to build a small 'data-mart' for better management of data used for analysis, forecasting and strategic planning. A SSIS package appears to be the best means for accomplishing this task every month and many other data upload packages will be produced as soon as I understand the process.

Thank you for your help.

|||Kirk Haselden's book on Integration Services is very helpful. I highly recommend it!

Wednesday, March 7, 2012

Creating ODBC link within SELECT statement

Is this possible. To explain myself, here is my situation. I created an
Excel Spreadsheet that uses an ODBC link to a SQL database. In order for
anyone to use this file on their PC, that same ODBC link must be setup. Is
their some code I can use within a Select Statement that will allow me to
bypass having to create an ODBC on everyone's PC?
Thanks.Hi Preacher Man,
You've cross-posted this to a bunch of newsgroups, some of which, for
example microsoft.public.fox.vfp.queries-sql, don't even apply to your
question. What you haven't done is post to a relevant Excel newsgroup. Try
posting this question (and your other one) there.
Someone will probably tell you that you can use a connection string or a
DSN-less connection as described here:
http://support.microsoft.com/kb/q165866/ . (GoogleGroups helped me find
that.)
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@.msn.com www.cindywinegarden.com
"Preacher Man" <nospam> wrote in message
news:uFEmV7eJGHA.3936@.TK2MSFTNGP10.phx.gbl...
> Is this possible. To explain myself, here is my situation. I created an
> Excel Spreadsheet that uses an ODBC link to a SQL database. In order for
> anyone to use this file on their PC, that same ODBC link must be setup.
> Is their some code I can use within a Select Statement that will allow me
> to bypass having to create an ODBC on everyone's PC?
> Thanks.
>

Friday, February 24, 2012

Creating multilple tables at once

I had a SQL db that i copied all the tables into excel and it generated the quereies in order to create those tables....Is there anyway i could excute all those table creations at once or would it be easier to just write an application that does that for me?i am a little confused on what you are asking. That said if you have generated several CREATE TABLE scripts and your question here is can you compile them all into one big script and execute it to recreate all the tables at once, the answer is YES you can.|||How i do it is I open the Query ananlyzer and input the CREATE TABLE query I see it say the command has excuted succesfully but when does the actual table show up in the SQL server? does it have automatically or do i need to do some eles to actually create the table? How would i go about creating the create table script?|||

since you are using the term "Query Analyzer" I will presume that you are using SQL 2000...

In Query Analyzer you need to display the object explorer. If memory servesI think it was View/Object Explorer but regardless its in the main menu somewhere. Once you have object explorer displayed explore down to an individual table (you may be able to select multiple again its been a while) and select Tasks/Generate Script. Also in Enterprise Mgr. I believe you can perform the equivilent in Enterprise Mgr. (but i seem to recall thoughts that I couldnt so dunno for sure on that). Overall its a VERY EASY PROCESS.

Then open up Query Analyzer, select open file/query, browse to the .sql file you created previously and a new query window with the script's contents will be shown. Hit ctrl & F5 to syntax check it (just a habit of mine personally) and then hit F5 again to execute it. Now via Enterprsie Mgr. and Query Analyzer Object Explorer you should see your new tables. You can interact with the new tables via TSQL Queries or via the GUI in Enterprise Mgr.

Derek

Friday, February 17, 2012

Creating Excel Output for Mac Excel 2004

I am experiencing issues with SQL Server Reporting Services 2000 when
rendering Excel (.xls) output on a Mac. The Mac is running Excel 2004 for
the Mac and appears to download the .xls file successfully, but just hangs
when attempting to open the file.
All other reporting services formats seem to render fine (html, pdf, .csv,
etc) though the HTML that gets rendered in Firefox or Safari doesn't look the
same nor nearly as nice as in IE, but it does render.
Are there service packs, hot fixes, or the like for either SSRS 2000 or
Excel 2004 for the Mac? Or is this just a case where that version of Excel
on the Mac isn't supported by SSRS 2000?
--
PaulHelo Paul,
Yes, this is a known issue in Reporting Services 2000 and Reporting
Services 2005.
For Reporting Services 2000, the MAC development group confirmed the
problem was in the .XLS file itself rendered from SQL Reporting Services.
Apparently there is certain information in the XLS file that is read by the
Mac version but not the PC version and it is this information that was
causing the file to not open or hang. The bug has been reported to the SQL
Reporting Services Product group, but I haven't been able to find a fix as
yet.
I'll include the VB code below which may helpful for you.
'Sample Program to automate process of opening and resaving XLS files
rendered by
Reporting Services and then email the file as an attachment to specified
address
locations
'This sample program was designed to run from the same location that the
XLS files
are rendered to
'Sample Command Line:
' c:>Project1.exe book1.xls
Private Sub Form_Load()
Me.Visible = False
pXLSFile = GetCommandLine()
ReSaveXLS (pXLSFile)
CreateEmail (pXLSFile)
Unload Me
End Sub
Private Sub ReSaveXLS(pXLSFile)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
'Start new instance of Excel using Automation:
Set xlApp = CreateObject("Excel.Application")
'Optional: Use if want to see Excel and let user close it:
xlApp.Visible = False
xlApp.UserControl = False
'Open the workbook that contains the data and macro:
Set xlBook = xlApp.Workbooks.Open(App.Path & "\" & pXLSFile)
'Save changes to the workbook:
'This line may need to be changed to call the SaveAs method.
xlBook.Save
'Quit Excel:
xlApp.Quit
'Release object variables:
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Private Sub CreateEmail(pXLSFile)
'from Q286431
' Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
'Const cdoSendUsingPort = 25
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' Set the CDOSYS configuration fields to use port 25 on the SMTP server.
With Flds
'.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
'The value from below should be the same as what is located
RSReportServer.config between the <SMTPServer> tags
Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.unistudios.com" '<remote SMTP server>
Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
) =10
Update
End With
' Build HTML for message body.
strHTML = "&
"
strHTML = strHTML & ""
strHTML = strHTML & ""
strHTML = strHTML & " This is the test HTML message body"
strHTML = strHTML & ""
strHTML = strHTML & "
"
' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
To = "matthofa@.microsoft.com" 'ToDo: Enter a valid email address.
From = "matthofa@.microsoft.com" 'ToDo: Enter a valid email address.
Subject = "This is a test CDOSYS message."
HTMLBody = strHTML
AddAttachment (App.Path & "\" & pXLSFile)
Send
End With
' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Sub
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For I = 1 To CmdLnLen
C = Mid(CmdLine, I, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next I
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray(1)
End Function
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

Creating excel file from DTS package

Hi,

I have a created a DTS packges which is reading data from sql server table, manipulate this data as required and then create a text file with that data. I created the text file using FileSystemObject. I was writing one field at a time to the text file.

I need to same thing but instead of creating text file, I need to create a excel file with each column from database going to separate column in excel sheet. I tried to do this with FileSystemObject, but it was wrting all the columns from database to one cell in excel sheet. How can I fix this problem?

Thanks!Am I missing something or can't you just create a data transformation task going from your database to a excel spreadsheet?

Create a conenction to a spreadsheet and a connection to a database and build your transformation. DTS will take care of everything else. If you need to play with filesnames etc you can do that after the package has been created (using the filesystem object)|||is there any sample to show that how to ceate an excel file after reading data from sql server?

Thanks|||start>programs>Microsoft SQL Server>Import and Export Data

follow the wizard. select your db>Select your output file (excel)>hit next>run immediately>done|||Sorry, I didn't explain my question properly. I can create an excel file and write data after reading from database but I also need to write totals, tax and grand totals after I finish writing all the records from the database. How can I add totals to the last line? I need to do all of this from a DTS package.

Thanks!|||I can create an excel file and write data after reading from database but I also need to write totals, tax and grand totals after I finish writing all the records from the database. How can I add totals to the last line? I need to do all of this from a DTS package.

Thanks!|||I 've create a template with the functions for addign totals, etc already built in. using VB SCRIPT, copy the template and populate it every time you run the DTS package.|||Could you please explain how can I create this template and copy it every time I need this?

Thanks|||'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

Dim objFSO, objFileTemplate, strFile

Set objFSO = CreateObject ( "Scripting.FileSystemObject" )
strFile = DTSGlobalVariables("strRootPath").Value & "Template.xls"
Set objFileTemplate = objFSO.GetFile ( strFile )
strMonth = Right ( "0" & DatePart ( "m", DTSGlobalVariables("dtStart").Value ), 2 )
strFile = DTSGlobalVariables("strPath").Value & _
DatePart ( "yyyy", DTSGlobalVariables("dtStart").Value ) & _
strMonth & _
" - " & _
DTSGlobalVariables("ID").Value & " " & DTSGlobalVariables("Id").Value & _
".xls"
DTSGlobalVariables("FileName").Value = strFile

If ( objFSO.FileExists ( strFile ) ) Then
Main = DTSTaskExecResult_Failure
Exit Function
End If

objFileTemplate.Copy strFile, 0

Main = DTSTaskExecResult_Success

End Function

Note: This is basically the code. You have a template in a directory. This vbscrip takes the template, copies it to a different directory. The name is obtained by using the 'Id' field and concatenating month and year.

If you want, we can take this offline, just let me know your email address.