Get Excel File When Run Sqlquery
Dec 23, 2007
Hi All
im using sqlserver2005 and i have sqlquery to get some fileds
now i need to get out put in excel file when i run sqlquery
can anyone explain me how can i do it...this is my query
select ta_targetpath from tblattributes where ta_pagelevel = 2 and ta_description like '%Do you want to watch this configuration in action%'
and ta_targetpath is not null
when i execute this i need to get result set in excel file...
thnx in advance
Hary
View 1 Replies
ADVERTISEMENT
Sep 3, 2007
Filling a DataTable from SqlQuery : If SqlQuery returns some null values problem ocurrs with DataTable.
Is it possible using DataTable with some null values in it?
Thanks
View 2 Replies
View Related
Jul 20, 2006
I have the Excel Connection Manager and Source to read the contents from an Excel file. For some reason couple of numeric fields from the Excel worksheet are brought over as nulls even though they have a value of 300 and 150. I am not sure why this is happening. I looked into the format of the fields and they are set to General in Excel, I tried setting them to numeric and that did not help.
All the other content from the excel file is coming thru except for the 2 numeric fields.
I tried to bring the contents from the excel source to a text file in csv format and for some reason the 2 numeric fields came out as blank.
Any inputs on getting this addressed will be much appreciated.
Thanks,
Manisha
View 5 Replies
View Related
Jul 14, 2015
Is there anyway to send excel file from ssis using send mail task without saving the excel file locally. I need to automate the process which involves loading the excel file from the database and send it to some people.
View 6 Replies
View Related
Mar 7, 2008
Hi,Here is my SQL Query.SQL = "insert into mnetwork..tblContactCorr(CorrespondentID,Name,Phone,Fax,Email,UserName,rowguid,Status,ChgPassword,lastlogin,MailNotification,USerLevel,LocationID,msrepl_tran_version)"SQL = SQL & " values( '" & drpCorr.SelectedValue & "', '" & txtName.Text & "', '" & txtphone.Text & "', '" & txtFax.Text & "', '" & txtEmail.Text & "', '" & txtUserName.Text & "', '" & mGuid & "', '" & drpstatus.SelectedValue & "', '" & "Null" & "', '" & getdate & "', '" & drpmn.SelectedValue & " ', '" & drpuserlevel.SelectedValue & "', '" & drplocation.SelectedValue & "', '" & "Null" & "')"Dim dbcommand As New SqlCommand(SQL, ObjConn)ObjConn.Open()dbcommand.ExecuteNonQuery()------>here is the problemdbcommand = New SqlCommand("select @@identity", ObjConn)Dim NewUserID = dbcommand.ExecuteScalarAfter executing i am getting error like this:Message "Syntax error converting from a character string to uniqueidentifier." StringI don't know how to convert mguid into uniqueidentifier.here is my batabase fields:ContactID-->this is auto incrementCorrespondentID--intName-varcharPhone-varcharFax-varcharEMail-varcharUserName-varcharrowguid--uniqueiduntifierstatus-tiniintchgpassword-snallintlastlogin--datetimemailnotification--smallintlocationid--intmsrepl_tran_version-uniqueiduntifier -(this is null)let me know whats wrong in this?
View 8 Replies
View Related
Jun 22, 2007
Could you pls let me know that when we use the parameters how the sql server ıs able to keep all the datas on the strıng type?and also how ıt can be provıde that securıty on system(how ıt ıgnore to do sql ınjectıon...).
View 1 Replies
View Related
Jun 18, 2008
Hello everyone,I am developing forums (Discussion Board) in C#.net 2005 with SqlServer. Right now i am having problem in fetching data from two tables.Here are the tables from which i want to fetch data.Topics Table Threads TableTopicID ThreadIDForumID TopicIDTopicName SubjectTopicDescription Replies UserID LastPostDatenow i want to fetch all the topic talbe data as well as total no of threads,Lastpostdate,UserID per topic.I am able to fetch topic table data and Total no of threads per topic through the following query.SELECT TopicID, ForumID, TopicName, TopicDescription,(SELECT COUNT(ThreadID) FROM Portal_Threads WHERE (TopicID = Portal_Topics.TopicID)) AS Threads FROM Portal_Topicsbut i am not able to fetch anoter two detail with subquery as i am getting error likeonly one expression can be specified in the select listorsubquery returned more than one value.can anyone tell me how can i fetch these two values per topic. should i use stored procedure and create temporary table and after fetching these values i can store it in temporary table and i can fetch values from that temporary table...please provide code snippet if possible as i've never used sqlserver before..Thanks in advance...Regards,Nil
View 8 Replies
View Related
Aug 14, 2004
Hi All,
I'm trying to pass in a parameter value from an array in a loop that is used in a sql query and the results are populated to an xml file. The trouble is that I'm only getting the colums values in the outputted xml file. So I feel that the paramter is not being read.
So can anyone help as I'm really stuck on this one. The code is as follows :
public void DisplayUserInfo()
{
ArrayList UserIdArrayList = IdentifyUserID();
foreach(string ShowUserIDString in UserIdArrayList)
{
try
{
SqlConnection SqlConn = new SqlConnection(DBConnString);
SqlConn.Open();
Console.WriteLine("Connected to DB");
SqlDataAdapter SqlAD = new SqlDataAdapter();
SqlAD.SelectCommand = new SqlCommand("Select * from UserSystemSpecs where UserName ='+ShowUserIDString.ToString()+'",SqlConn);
DataSet ds = new DataSet();
SqlAD.Fill(ds);
ds.WriteXml(".\ResultsXML.xml", XmlWriteMode.WriteSchema);
}
catch (Exception ex)
{
throw new Exception ("Error Connecting to DB. " + ex.Message);
}
//SqlConn.Close();
}
}
Thanks
Garry
View 2 Replies
View Related
Jul 25, 2015
Trying to upload excel in server where excel is not installed. BIDs was there in the server, when i am trying to craete Excel source I am not able.what the workround for this.. How to upload excel without excel installed on the server.
View 4 Replies
View Related
Nov 19, 2007
I am using a Excel Source to get the data from an excel file to sql server 2005 table. A couple columns are coming in a double precision float, but some values have characters in them, but those values are coming out as null, even though I changed the datatype from float to unicode string. Any inputs on resolving this will be much appreciated.
Thanks,
Manisha
View 4 Replies
View Related
Sep 13, 2015
We have 10 sheets in Excel File and 10 sheet contains errror data. How to load 9 sheets data in to 1 destination and error data in to other destination?
View 4 Replies
View Related
Dec 18, 2006
i have an SSIS package that exports to an excel file. This works fine. the problem is that it appends the data instead of overwriting the file. Is there any way to overwrite the file like you can with a flat file? I have to email the file everyweek and don't want to have to clear it out manually. Any help would be appreciated
View 2 Replies
View Related
Nov 16, 2006
I have a this SP that inserts values into a table with results from a query, but at the same time I want to insert some default values.But thats NOT working the way I hoped for, actually sqlserver 2005 dont let me create this SP at all."Incorrect syntax near the keyword 'DEFAULT'."Can someone please tell me how I can achieve this? create procedure %PROC% ( @Ordre_ID int
)
asbeginIF NOT EXISTS(SELECT Ordre_ID FROM tbl_Ordre WHERE Ordre_ID = @Ordre_ID AND Ordrestatus IN ('2', '3', '4'))BEGIN return 0;ENDIF EXISTS(SELECT Ordre_ID FROM tbl_Faktura WHERE Ordre_ID = @Ordre_ID)BEGIN return 0; ENDBEGIN TRANSACTIONINSERT INTO tbl_Faktura( Ordre_ID ,PostNummer ,KID ,Fakturastatus ,Kontonummer ,Forfallsdato ,Belop ,BekreftetBetaltDato ,Faktura_GUID ,Adresse ,PostBoks ,Fornavn ,Etternavn ) (SELECT O.Ordre_ID ,K.PostNummer ,DEFAULT
,DEFAULT
,SI.Kontonummer
,(getdate()+14) ,v_OTS.TOTALBELOP ,DEFAULT
,DEFAULT
,K.Adresse
,K.PostBoks
,K.Fornavn
,K.Etternavn
FROM
tbl_Ordre AS O INNER JOIN
tbl_Kunde AS K ON
O.Kunde_ID = K.Kunde_ID
INNER JOIN
v_OrdreTotalSum AS v_OTS ON
O.Ordre_ID = v_OTS.Ordre_ID
,tbl_StatiskeInnstillinger AS SI WHERE
O.Ordre_ID = @Ordre_ID
)
UPDATE
tbl_Ordre
SET
Ordrestatus = '6'
WHERE Ordre_ID = @Ordre_ID COMMIT end
go
View 3 Replies
View Related
Apr 9, 2008
Hi I'am practically new in C#, so I want to ask you guys some question.Let say I have this query:"Select EmployeeID, EmpName from PI_Employee"How can I retrieve the result from EmployeeID column and EmpName column and put it into collections of array, so I can call the array and use it again in another function. Can I possibly do that in C# ? if so, how ? please help me guys, I'm on the edge of nervous wreck in here so I could use a little help, any kinds of help. Thanks. Best Regards.
View 9 Replies
View Related
Apr 9, 2008
Hi I'am practically new in C#, so I want to ask you guys some question.Let say I have this query:"Select EmployeeID, EmpName from PI_Employee"How can I retrieve the result from EmployeeID column and EmpName column and put it into collections of array, so I can call the array and use it again in another function. Can I possibly do that in C# ? if so, how ? please help me guys, I'm on the edge of nervous wreck in here so I could use a little help, any kinds of help. Thanks. Best Regards.
View 2 Replies
View Related
Sep 25, 2006
Good Day to all,
Hope you could help me w/ my project.
Im creating a DTS Package. The source data will be coming from an excel file going to my SQL table. The DTS package is scheduled to execute daily, but the source data will be coming from different excel filename.
Example, today the DTS will get data from Data092506.xls. Then tomorrow, the data will be coming from Data092606.xls.
How can I do this? The DTS I've already done has a fixed source data file.
Please help.
Thank you so much.
God Bless.
View 9 Replies
View Related
Aug 26, 2015
I have a ssis package where I need to have excel destination. In the Excel file, I need to have few rows with some text and then populate data below the text. One the text is like this:
Data as of: 08/25/2015
if the report ran today, then Data as of will have Yesterday. So, if the user opens that excel file after a week, then user should see same Data as of: 08/25/2015. not today()-day(1).
I was planing to handle on excel side with today()-day(1). but it only works the day it was run. Then the excel file is open after few days later, then it might as Data as of: 08/30/2015 which is not true. It should still stay Data as of:
08/25/2015 on what ever date the excel file is open. The SSIS package runs only once.
How do I handle this so that whenever user open the file, they will see Data as of: 08/25/2015. This is not a column in excel. It is like a description of data in excel.
View 3 Replies
View Related
Dec 28, 2007
hi all;
1. Excel file Source--> monthly Revenue details
2. Derived Colum Transoformations
3. Oledb Destination
its my flow in one of my packates (ETL job)
Excel file contains monthly revenue details, i wanna import the excel data to my database staging table, so i've created the package.
its working fine...
Problem
if we change the new data for the next month and running the package its not running;
the same file, same format, only we delete the contents, of the file except first row of the excel sheet,
and pasting the new data;
new data is coming from Oracle DataBase in the form of excel sheet ( manually they will copy the data and sending to us)
i open that package in design mode and while double clicking the excel file source it says <column name>'s Meta Data needs to be synchronized
Do you want to Fix this issue automatically with the available external column's meta data
Clearly noted that its a data type issue; i have changed the corresponding data types as it is in the previous Excel sheet which is equivalant to the Table its copying to.
now the package is running with validation warnings, External Column "Invoice Amount" needs to be updated...etc. some 2 or three warning messages i can able to see in the package Execution wizard,
ok, i'm ready to accept these warnings, and i want my package running from my server;( packages had been deployed in to the Centeralized server; every time if we want to run the package, we have the asp.net webpage, that is executing the package in an On_click event)
The package is not running from the server, its due to the meta data change in the Excel file( i guess)
please suggest me some guide lines to resolve this meta data issue, i want my excel sheet meta data should not change when we have new updates in it;
otherwise suggest me some solutions that i can validate the excel sheet before running the package and testing whether the data is in correct format or not? its a kind of Data Profiling activity;
i know its some what crazy, but i need to maintain the system with permanent solution, instead of facing this meta data mismatch issue!!!
some what lenthy explanation--> its needed for my dear powerful microsoft responders. i think i 've explained my problem clearly, if i don't let me know your queries, i'll try my level best.
View 3 Replies
View Related
Jan 3, 2007
Dear all,
I am deploying programatically an Excel 2007 file to a SQL Server 2005 Reporting Server. The problem is that if a file with the same name already exists, that file isn't replaced. I would like the opposite to happen. I'm using the following code:
--Executable
set svr=http://w3sdwsqld1/reportserver
set src_fld="\w3sdwsqld1\deploy\SAD\ECRANS\UPDATES_20061127_190000\Ecrans\AM\Associados\"
set dest_fld="Associados"
set script="\w3sdwsqld1\deploy\SADECRANS\UPDATES_20061127_190000\Ecrans\AM\Associados\PublishReports.rss"
REM Sample: deploy.bat http://w3sdwsqld1/reportserver "\w3sdwsqld1\deploy\SAD\ECRANS\UPDATES_20061127_190000\Ecrans\AM\Associados\" "Associados" "\w3sdwsqld1\deploy\SADECRANS\UPDATES_20061127_190000\Ecrans\AM\Associados\PublishReports.rss"
for /R %src_fld% %%f in (*.xlsx) do rs -i %script% -s %svr% -v ParentFolder=%dest_fld% -v reportP="%%~nf" -v path=%src_fld%
PAUSE
--rss Code
'
' Script Variables
'
' Variables that are passed on the command line with the -v switch:
'
' (a) parentFolder - corresponds to the folder that the script creates and uses
' to contain your published reports
' (b) reportP - corresponds to the report to publish
Dim ROOT As String = "/SAD/Ecrans/Ecrans/AM"
Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = ROOT + "/"+ parentFolder
Dim filePath As String = path
Dim report As String = reportP
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
'Create the parent folder
Try
rs.CreateFolder(parentFolder, ROOT,Nothing)
Console.WriteLine("Parent folder {0} created successfully", parentFolder)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
'Create shared data source
'CreateSampleDataSource("Solucao_Integrada", "OLEDB-MD", "Data Source=dwareas1;Initial Catalog=SAD_Solucao_Integrada")
'Publish the sample reports
PublishReport(report)
End Sub
Public Sub CreateSampleDataSource(name As String, extension As String, connectionString As String)
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
definition.ConnectString = connectionString
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = extension
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
'Use the default prompt string.
definition.Prompt = Nothing
definition.WindowsCredentials = False
Try
rs.CreateDataSource(name, parentPath, False, definition, Nothing)
Console.WriteLine("Data source {0} created successfully", name)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".xlsx")
Console.WriteLine(reportName)
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
Try
rs.CreateResource(reportName + ".xlsx", parentPath, True, definition, "application/x-excel", Nothing)
Catch e As Exception
Console.WriteLine(e.Message)
Console.WriteLine("Failed to publish report")
End Try
End Sub
--------------------------------------------------------------------------------------------------------------------
Any thoughts? Many thanks,
Pedro Martins
Portugal
View 3 Replies
View Related
Aug 2, 2007
I hope someone can help me with this - I started receiving this error message in the past month or so when I open a csv report and save it as an Excel file in a folder I use on my VPN and in My Documents. It does not show up when I save it to my Desk Top.
I have Microsoft Office Student and Teacher and Office XP Professional installed on my notebook. I tried to uninstall Office XP and it would not let me. Something about a "patch could not be opened......"
The error message is as follows:
Header: .NET-BroadcastEventWindow.2.0.0.0.33c0d.0.EXCEL.EXE-Application Error
Excel error message The instruction at 0x0beab865 referenced memory at "0x00000008"
The memory could not be "read".
Click ok to terminate the program.
I hope someone could please help me with this I received 60 - 80 csv files a week and everythime I save on I get this pop up message!
Thank you!
Leslie
View 1 Replies
View Related
Jul 21, 2015
I'm importing a multi tab spreadsheet using Import wizard, which I understand to use the same internals as SSIS. The total number of columns in the spread sheet will be over 500. The import wizard defaults everything to varchar 255. I understand there is an XML file I can manipulate to change this and they are located
C:Program FilesMicrosoft SQL Server100DTSMappingFiles
Assuming one of these will control Excel defaults, which one is it? None of the names lend themselves to the Excel as a source. SqlClientToMSSql10?
View 6 Replies
View Related
Apr 25, 2002
Hi guys,
I am converting a xls file to csv file. When I am converting, the values in the columns 00 and 05 are converted into 0 and 5 respectivly. I tried changing column type from general to text format and tried converting it with no luck.
It is an urgent need and if anyone have any solution, can u please post it here. Thanks
Joy
View 1 Replies
View Related
Jun 19, 2000
I tried to dts a table to an excel file. The data types of all the columns in the table are varchar. When it dts to excel file, excel force every column to be text. So every value of every cell of the excel has a single quote before it (not in the cell itself, but in the value shown space right below the toolbar). I also tried to dts the table into a excel template which I predefined all cells to be text type. The strange thing is some of the columns do not have the single quote anymore, but others still keep them. Since the other system that going to process the excel file does not expect the single quote, the process always fails.
Would anybody tell me how to get rid of the single quote?
Thanks a lot.
Qing
View 2 Replies
View Related
Mar 29, 2007
Hi,
I have to DTS a excel file to sql server 2000. The DTS package works fine. I have issue with one column that has value
450
800
900
45TH
23SI
800
390
100
30SI
If given the cell format general/text only that have alphanumeric characters are upload and not others. What should be done to upload all the values for this column.
thanks in advance.
View 1 Replies
View Related
Jul 31, 2007
How do i import a Excel file into a table i have created in my database in SQL server 2005???
View 10 Replies
View Related
Oct 5, 2001
Hi, folks,
How can I empty an existing excel file before using DTS to export new data in this excel file? Or is there any way to delete this excel file from DTS task?
Thank you very much
Tony
View 4 Replies
View Related
Feb 3, 1999
I'm trying to write a DTS package that reads data from an excel spreadsheet. I'm having a problem getting all the data from the spreadsheet, seems that OLE DB is "too" smart. There is one column that has either numeric values or text values in its row cells. When I browse the spreadsheet in DTS (transform properties, browse button) I only see the text values. OLE DB has placed nulls or blanks into the cells with the numeric values. If I edit the spreadsheet to change the column header to contain a number, then the browse window shows only the numeric values and blanks out the text values. Any suggestion on how to get OLE DB/DTS to treat the numeric values as text? In the spreadsheet, I've tried changing the cell formats to text and to general. This had no effect.
View 1 Replies
View Related
Feb 7, 2002
I need to select a list of rows from excel file.
I formed my query in this way :
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="MOC02c:empest/xls";Extended properties=Excel 97-2000')...xactions
This gives an error
Error is
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: Could not find installable ISAM.]
If anybody knows how to read from an excel file to a query analyser , pelase reply.
Regards
Suresh
View 1 Replies
View Related
Aug 20, 2002
I have a stored procedure. This proc returns some data that needs to be put in an excel format. Is it possible to create a excel file to have the result of a select statement from the database?
Thanks
View 1 Replies
View Related
Sep 28, 2003
I have to generate reports in Excel formats.I send the appropriate content type through header() function of PHP.But I can't get the <td> colors when using css sheets.
Following problem occurs:
1. Image doesn't come.
2.<td> does'nt take css style.
Following is the code snippet:
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=pareto_combined.xls");
?>
<link href="../../../extra/sheets/SSheet.css" rel="stylesheet" type="text/css">
<tr colspan=8>
<td height=50> <img src='../../../extra/images/log.jpg'></td>
<td align=right><img src='../../../extra/images/mickey_sup.jpg'></td>
</tr>
<?php
$dateF=$_REQUEST['dateF'];
$dateT=$_REQUEST['dateT'];
$agentID=$_REQUEST['agentID'];
?>
<tr>
<td class='graybg'><?php echo $agentID</td>
<td class='graybg'><?php echo $dateF?></td>
<td class='graybg'><?php echo $dateT?></td>
</tr>
View 1 Replies
View Related
Oct 28, 2005
Hello All.
I need to execute an excel file (built with macro) whenever a date change is detected between 2 fields in my sql table.
if @Date1<>@Date2
begin
DECLARE @command varchar(1000)
SET @command='d:Refresh_ABC.bat'
exec xp_cmdshell @command
.
.
.
In my Refresh_ABC.bat, I have the following line
Start Excel.exe "D:ABC.xls"
When I tested the above script (from Declare... to @command) in query analyzer, nothing seems to happen. It shows The command(s) completed successfully. But my excel file was not refreshed at all. When I ran the batch file Refresh_ABC.bat on it's own, ABC.xls was refreshed so the batch file is working.
Next test, I placed the line Start Excel.exe "D:ABC.xls" on SET @command = ......... line. Same problem, nothing happened.
Any idea what went wrong. Please advise. Thank you.
Best regards
Teck Boon
View 1 Replies
View Related
May 12, 2006
hey
I am just trying a simple query of an Excel file.
Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:MyFile.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
and i am getting this error
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: The provider did not give any information about the error.].
I know for a fact that the path is correct and that it is the path of the server. So what is the problem with this??
tibor
View 3 Replies
View Related
Jun 4, 2006
I've created a dts package that exports data to an excel. The data exports okay, but I'd like to make a few changes on how the data is exported.
First, when the data exports to the excel file, it always creates a new excel sheet. How can I map the data to the existing sheet in the Excel file? I have an existing sheet named 'Sheet1'. I've deleted the other two sheets in the excel file, so there is only one sheet. When I created the destination table in the dts package for the data transformation task, I specified the name as 'Sheet1', but when it exports, it creates a new sheet named 'Sheet11'. I haven't been able to correct this.
Second, I'd like to either ammend data to the last row in the excel file, which I'd have to know the last record that was inserted from the SQL table. Or probably much easier, simply drop the existing sheet in the excel file and simply re-create and insert.
How can I do this?
Thanks,
-D-
View 1 Replies
View Related