PASTE SQL RESULTS INTO EXCEL - Funny Results
Jan 30, 2008
Hi, when I copy and paste results from query analyzer into Excel it appears that values with zeroes at the end loose the zeroes. Example, if I copy and paste V128.0 into an Excel cell it comes out as V128 or if I copy 178.70 it displays as 178.7 - any ideas? I'm using SQL Enterprise Manager for 2000.
View 6 Replies
ADVERTISEMENT
Apr 1, 2007
hi, like, if i need to do delete some items with the id = 10000 then also need to update on the remaining items on the with the same idthen i will need to go through all the records to fetch the items with the same id right? so, is there something that i can use to hold those records so that i can do the delete and update just on those records and don't need to query twice? or is there a way to do that in one go ?thanks in advance!
View 1 Replies
View Related
Mar 25, 2015
I have four tables: Customer (CustomerId INT, CountyId INT), County (CountyId INT), Search(SearchId INT), and SearchCriteria (SearchCriteriaId INT, SearchId INT, CountyId INT, [others not related to this]).
I want to search Customer based off of the Search record, which could have multiple SearchCriteria records. However, if there aren't any SearchCriteria records with CountyId populated for a given Search, I want it to assume to get all Customer records, regardless of CountyId.
Right now, I'm doing it this way.
DECLARE @SearchId INT = 100
SELECT * FROM Customer WHERE
CountyId IN
(
SELECT CASE WHEN EXISTS(SELECT CountyId FROM SearchCriteria WHERE SearchId = @SearchId)
THEN SearchCriteria.CountyId
[Code] .....
This works; it just seems cludgy. Is there a more elegant way to do this?
View 4 Replies
View Related
Nov 22, 2005
Hi All
I've been googling this for a while now and can't seem to find any elegant answers.
I'm looking for an automated way to present a FORMATED Excel Spreadsheet to the Customer from a stored procedure output.
Can anyone advise me the best method of doing this - should I / can I assign an Excel Template to the DTS Task output ?
His mind is set on Excel and the formatting is basic and easy to write in a Macro which I've done, but this requires human interaction to finish the task (Automated Run Once on opening etc).
In an ideal world an individual would send an email to the Server with two formated parameters (@FromDate & @ToDate) and would be emailed back a ready formatted S/Sheet. But I believe he would be willing to just select the relevant SpreadSheet for the Daily / Weekly / Monthly periods dumped.
Thanks
GW
View 2 Replies
View Related
Feb 12, 2008
Hello. I currently have a website that has a table on one webpage. When a record is clicked, the primary key of that record is transfered in the query string to another page and fed into an sql statement. In this case its selecting a project on the first page, and displaying all the scripts for that project on another page. I also have an additional dropdownlist on the second page that i use to filter the scripts by an attribute called 'testdomain'. At present this works to an extent. When i click a project, i am navigated to the scripts page which is empty except for the dropdownlist. i then select a 'testdomain' from the dropdownlist and the page populates with scripts (formview) for the particular test domain. what i would like is for all the scripts to be displayed using the formview in the first instance when the user arrives at the second page. from there, they can then filter the scripts using the dropdownlist.
My current SQL statement is as follows.
SelectCommand="SELECT * FROM [TestScript] WHERE (([ProjectID] = @ProjectID) AND ([TestDomain] = @TestDomain))"
So what is happening is when testdomain = a null value, it does not select any scripts. Is there a way i can achieve the behaivour of the page as i outlined above? Any help would be appreciated.
Thanks,
James.
View 1 Replies
View Related
May 14, 2008
Hi All,
I have a stored proc which is executing successfully...but the results of that stored proc are displaying in the Messages Tab instaed of results Tab. And in the Results Tab the results shows as 0..So, Any clue friends..it is very urgent..I am trying to call this stored proc in my Report in SSRS as well but the stored proc is not displaying there also...Please help me ASAP..
Thanks
dotnetdev1
View 4 Replies
View Related
Jun 9, 2008
I've got several reports that are sent to recipients in excel format and was wondering if there is any way to have the columns formatted so they are spaced according to the length of the header.
View 1 Replies
View Related
Jun 18, 2008
Hi all, I have the following SQLDataSource statement which connects to my Gridview:<asp:SqlDataSource ID="SqlDataSourceStandings" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT P.firstName, P.lastName, T.teamName, IsNull(P.gamesPlayed, 0) as gamesPlayed, IsNull(P.plateAppearances,0) as plateAppearances, IsNull( (P.plateAppearances - (P.sacrifices + P.walks)) ,0) as atbats, IsNull(P.hits,0) as hits, P.hits/(CONVERT(Decimal(5,2), IsNull(NullIF(P.atbats, 0), 1))) AS [average], (P.hits + P.walks)/(CONVERT(Decimal(5,2), IsNull(NullIF( (P.atbats + P.sacrifices + P.walks) , 0), 1))) AS [OBP], (P.hits - (P.doubles + P.triples + P.homeRuns) + (2 * P.doubles) + (3 * P.triples) + (4 * P.homeRuns)) / (CONVERT(Decimal(5,2), IsNull(NullIF(P.atbats, 0), 1))) AS [SLG], P.singles, P.doubles, P.triples, P.homeRuns, P.walks, P.sacrifices, P.runs, P.rbis FROM Players P INNER JOIN Teams T ON P.team = T.teamID ORDER BY P.firstName, P.lastName"></asp:SqlDataSource>There are 8 teams in the database, and somehow the average and obp results are as expected for all teams except where T.teamID = 1. This doesn't make sense to me at all! For example, I get the following results with this same query: First NameLast NameTeamGPPAABHAVGOBPSLG1B2B3BHRBBSACRRBI
BrianAustinHope83432230.7187500.7352941.15625014612201221
GabrielHelbigSafe Haven62119141.0000000.9375002.1428576404111519
MarkusJavorSafe Haven82927200.8695650.8000001.21739114501021218
RobBennettMelville83029240.8275860.8333331.55172411904102117
AdamBiesenthalSafe Haven82929210.9130430.9130431.56521712631001015
ErikGalvezMelville82625180.7200000.7307691.24000011322101015 As you can see, all teams except for Safe Haven's have the correct AVG and OBP. Since AVG is simply H/AB, it doesn't make sense for Gabriel Helbig's results to be 1.00000. Can anyone shed ANY light on this please?Thank you in advance,Markuu ***As a side note, could anyone also let me know how I could format the output so that AVG and OBP are only 3 decimal places? (ex: 0.719 for the 1st result)***
View 2 Replies
View Related
Oct 19, 2007
Hi,
I have a web form that lets users search for people in my database they wish to contact. The database returns a paged set of results using a CTE, Top X, and Row_number().
I would like to give my users to option of removing individual people from this list but cannot find a way to do this.
I have tried creating a session variable with a comma delimited list of ID's that I pass to my sproc and use in a NOT IN() statement. But I keep getting a "Input string was not in a correct format." Error Message.
Is there any way to do this? I am still new to stored procedures so any advice would be helpful.
Thanks
View 3 Replies
View Related
Feb 20, 2015
I have been trying to find a way to export the results of a query to a csv for use in excel but cannot.
View 2 Replies
View Related
Mar 8, 2006
Hi,I am using a .dqy file to import some rows from a sql server 2003database to microsoft excel. Unfortunately, I have am importing morerows than excel can handle. Is there a way around this?It appears that there is no equivalent of the LIMIT(offset, number ofrows to return) function of mysql in tsql. Had there been anequivalent, I would have created multiple .dqy files, which would querythe database for pages of results as appropriate. There is an upperlimit to the number of records that there can be in the database, sothis would have been a feasible solution.Also, I must use .dqy files (or something equivalen) because thequeries are invoked from a website, and it is necessary to download theresults, sort/filter, etc. (in excel).Thanks for any suggestions.
View 4 Replies
View Related
Jan 12, 2007
Hello,
I have tried to use a DaraReader Source to execute a SQL Server 2000 proc, and send the results to an Excel Destination.
The proc is named spv_CDGetFuelManDuplicates. Within the proc, temporary tables are created and dropped. When I attempt to set 'Exec dbo.spv_CDGetFuelManDuplicates' for the SqlCommand property of the DataReader, I get an error message indicating that my temporary tables are invalid objects.
The DaraReader is using an ADO.NET Connection Manager.
Should I be using an Execute SQL Task instead?
Thank you for your help, the proc code is below.
cdun2
********************************
alter PROCEDURE dbo.spv_CDGetFuelManDuplicates
AS
--Isolate Accounts and Contact Info per the View criteria
SELECT
RTRIM(Acctcode) AS AcctCode,
RTRIM(CompanyName)AS CompanyName,
MMS#, RTRIM(Phone) AS Phone
INTO #CorrectAcctCodes
FROM dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
--Isolate duplicate phone numbers
--per the view criteria
SELECT
RTRIM(Phone)AS Phone, COUNT(*) AS RecordCount
INTO
#DupPhoneNumbers
FROM
dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
GROUP BY
RTRIM(Phone)
HAVING
(COUNT(*)>1)
--Isolate duplicate Company Names
--per the View criteria
SELECT
RTRIM(CompanyName)AS CompanyName,
COUNT(*) AS RecordCount
INTO
#DupCompanyName
FROM
dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
GROUP BY
RTRIM(CompanyName)
HAVING
(COUNT(*)>1)
--Result with duplicate company or phone numbers
SELECT
Acctcode, CompanyName, MMS#, Phone
FROM
#CorrectAcctCodes
WHERE
Phone IN (SELECT Phone FROM #DupPhoneNumbers)
OR
CompanyName IN (SELECT CompanyName FROM #DupCompanyName)
ORDER BY
Phone, companyname
--Drop the temp tables
DROP TABLE #CorrectAcctCodes
DROP TABLE #DupCompanyName
DROP TABLE #DupPhoneNumbers
View 2 Replies
View Related
Oct 27, 2007
Hi all,
I am just wondering if anyone has a code to send query results to a spreadsheet package eg. MS Excel.
i) Automatically send the query result(s) to the package
ii) open the spreadsheet package;
Thanks.
View 1 Replies
View Related
Apr 29, 1999
Wendy,
I do not know if you can see my reply after yours. Any way I try it here again.
In the DTS Export Wizard, after select the source (SQL Server)and destination (Excel),
I have 2 choices:Table copy or query.
When I use query, I can place my sp there, and the export works fine exactly as you recommended.
Thanks a lot.
But when I selected a table copy, I was given a "Select Source Tables" popup form, I can
see all the table names there, but can not find any views in the database. I do not know why.
Am I in the right place this time?
Thank you very much for your quick help.
Charlie
View 1 Replies
View Related
May 2, 2007
I'm looking for a tool that can schedule stored procedures or queries and save the results to pdf or excel (preferrably both). SQL Server 2000, so 2005 reporting services are out, though if that has the capability I'd like to know because that might convince some of the powers that be to upgrade.
View 4 Replies
View Related
May 16, 2007
Code:
-- (1) Number of calls received for each priority of call [for a specified date range]
declare @startdate datetime,
@finishdate datetime
select RM.fldPriorityCode as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
group by RM.fldPriorityCode
union
select
'Total' as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
order by RM.fldPriorityCode asc
Results:
PriorityCalls
120
22912
3152
4571
54
Total3659
I would like to transfer these results to an excel sheet. For instance when the user opens up the excel worksheet and types in for a example a start date: 01-01-2007 and an end date: 03-05-2007 (into textboxes) then clicks a button say called 'Get stats' and then the results appear on the sheet.
How can this be done?
View 1 Replies
View Related
May 16, 2007
-- (1) Number of calls received for each priority of call [for a specified date range]
declare @startdate datetime,
@finishdate datetime
select RM.fldPriorityCode as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
group by RM.fldPriorityCode
union
select
'Total' as 'Priority',
count(RM.fldRequestID) as 'Calls'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldRequestDate between '01-01-2007' and '03-05-2007'
and RM.fldRequestFlag like 'D'
order by RM.fldPriorityCode asc
Results:
PriorityCalls
120
22912
3152
4571
54
Total3659
I would like to transfer these results to an excel sheet. For instance when the user opens up the excel worksheet and types in for a example a start date: 01-01-2007 and an end date: 03-05-2007 (into textboxes) then clicks a button say called 'Get stats' and then the results appear on the sheet.
How can this be done?
View 2 Replies
View Related
Oct 12, 2012
I am running a SQL stored procedure which runs 3 queries on 3 different SQL tables. What is my best option to export the results of these 3 queries to excel?
If it matters they are all SELECT queries, and at most will return < 500 rows.
View 6 Replies
View Related
May 16, 2007
Hi,
I am trying to create a DTS package that uses a sql stored procedure to generate a set of results and export those results to an excel spreadsheet on a server.
The trick is that the stored procedure accepts a parameter for Bank_Number (there are 10 of them). Therefore i was wondering if there was a way to somehow create the package to run the stored proc 10 times, each with a different bank number as the parameter and generate 10 different excel spreadsheets, one for each bank with it's results.
Can this be done using DTS or do i have to try another method?
thanks
scott
View 1 Replies
View Related
Nov 9, 2007
I'm new to Integration Services and going through the learning challenges one often faces when employing unfamiliar technology. I've created a simple package that executes a parameterized stored procedure and returns the results (multiple rows) into an object variable. How do I export the results to an XLS file? Do I have to use a script task to do this?
Regards,
Orlanzo
View 12 Replies
View Related
Apr 29, 1999
Hi,
Does anyone know the method to transfer result data of a view or stored procedure
in MS SQL 7.0 to MS Access or Excel , Manually or automatically? I did not find the
right tool in SQL 7 to do so.
I notice we can transfer table from SQL 7 to MS Access / Excel through DTS. But did not
find any tool/menu to transfer result of view / stored procedure.
I am new to SQL 7. Maybe this is a silly ?. Any help will be appreciated.
Charlie
View 2 Replies
View Related
Dec 1, 2005
Hi,
In SQL Server,
does anybody provide the steps for create a Package for exporting the query results to Excel environment?
I just know that click the "Export", then choose the query file to export to Excel.
I want to know how to create the Package to export it.
Please let me know, thanks.
View 3 Replies
View Related
Jan 2, 2007
Is it possible to restrict the Users to Export Report Results only to Excel ?
So instead of the default drop down options of csv, pdf, tiff,Web Archive,Web Archive etc... can we get it to just display Excel.
Any help would be appreciated.
View 1 Replies
View Related
Jul 1, 2015
is it possible to replicate this in SSRS I wonder??I have included the code of the fields used and a snapshot of some data, and also how the Pivot looks in Excel.
SELECT
TARNSubmissionID,
ISSBand,
BPTLevelAchieved,
FinancialYearOfDischargeOrDeath,
FinancialQuarterOfDischargeOrDeath,
FinancialMonthOfDischargeOrDeath,
CalendarMonthNameOfDischargeOrDeath,
[code]...
View 4 Replies
View Related
Jun 30, 2015
Goal: To run a stored procedure and export its results to Excel.
Challenge: The stored procedure produces multiple result sets. We want to programmatically export each result set into just 1 Excel file but into different Worksheets. Ex: result set 1 into Worksheet 1, result set 2 into Worksheet 2 and so on. Tools like
BCP utility and OPENROWSET are not enabled for use on the server. So those are out of the league for this one.After I run "EXEC [sp_select_ view_ columns_ from_pp]" -- Within the Results tab of Microsoft SQL Server Management Studio, I see:
viewName columnName columnDataType columnLength column
test test_id varchar 8 0
viewName columnName columnDataType columnLength column
test1 test1_id varchar 8 0
viewName columnName columnDataType columnLength column
test2 test2_id varchar 8 0
As you can see from above, that stored procedure sp_select_view_columns_from_pp is producing multiple result sets within the same Results tab in Microsoft SQL Server Management Studio. We want to make it so it exports to Excel into its own worksheets.
Code:
ALTER PROCEDURE [dbo].[sp_select_view_columns_from_pp]
AS
DECLARE @object_id INT;
DECLARE cur CURSOR FOR SELECT object_id
[code]....
View 7 Replies
View Related
Jan 2, 2014
Is there a way to export query results to an excel fie and add that file as an attachment in the email? All this has to be done using SQL query and it needs to be automated. My coworker tried using Openrowset and BCP, but it is not working.
View 3 Replies
View Related
Oct 12, 2007
Hi All,
I have two SQL queries that we would like to automate. Ideally we want them to both be scheduled to run and dump their results to a single Excel spreadsheet with two workbooks, one for each query
Is it possible to do this? If not, sending each query to a seperate XLS or CSV file would be OK
Here are the queries:
SELECT p21_view_unvouched_po_currency_report.unvouched_document_type, p21_view_unvouched_po_currency_report.date_created, p21_view_unvouched_po_currency_report.unvouched_document_no, p21_view_unvouched_po_currency_report.line_number, p21_view_unvouched_po_currency_report.po_no, p21_view_unvouched_po_currency_report.po_line_number, po_line.created_by, p21_view_unvouched_po_currency_report.item_id, p21_view_unvouched_po_currency_report.item_desc, p21_view_unvouched_po_currency_report.qty_received, p21_view_unvouched_po_currency_report.qty_vouched, p21_view_unvouched_po_currency_report.order_date, p21_view_unvouched_po_currency_report.location_id, p21_view_unvouched_po_currency_report.supplier_id, p21_view_unvouched_po_currency_report.supplier_name, p21_view_unvouched_po_currency_report.extended_cost_home
FROM P21.dbo.p21_view_unvouched_po_currency_report p21_view_unvouched_po_currency_report, P21.dbo.po_line po_line
WHERE po_line.po_no = p21_view_unvouched_po_currency_report.po_no AND po_line.line_no = p21_view_unvouched_po_currency_report.po_line_number
and
SELECT p21_view_unvouched_po_currency_report.unvouched_document_type, p21_view_unvouched_po_currency_report.date_created, p21_view_unvouched_po_currency_report.unvouched_document_no, p21_view_unvouched_po_currency_report.line_number, p21_view_unvouched_po_currency_report.po_no, contacts.last_name, p21_view_inventory_return_hdr.buyer_id, p21_view_unvouched_po_currency_report.po_line_number, p21_view_unvouched_po_currency_report.item_id, p21_view_unvouched_po_currency_report.item_desc, p21_view_unvouched_po_currency_report.qty_received, p21_view_unvouched_po_currency_report.qty_vouched, p21_view_unvouched_po_currency_report.order_date, p21_view_unvouched_po_currency_report.location_id, p21_view_unvouched_po_currency_report.supplier_id, p21_view_unvouched_po_currency_report.supplier_name, p21_view_unvouched_po_currency_report.extended_cost_home
FROM P21.dbo.contacts contacts, P21.dbo.p21_view_inventory_return_hdr p21_view_inventory_return_hdr, P21.dbo.p21_view_unvouched_po_currency_report p21_view_unvouched_po_currency_report
WHERE p21_view_inventory_return_hdr.return_number = p21_view_unvouched_po_currency_report.unvouched_document_no AND contacts.id = p21_view_inventory_return_hdr.buyer_id
View 4 Replies
View Related
Jul 9, 2015
I am trying to fetch records from excel sheet using Select Query but I am getting the error message saying
"Msg 7302, Level 16, State 1, Line 1
Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)"."
Here is my Query,
sp_configure 'show advanced options',1
reconfigure with override
go
sp_configure 'Ad Hoc Distributed Queries',1
reconfigure with override
go
reconfigure
SELECT *
FROM OPENROWSET
('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:M2MworkedworkedBOS.xlsx;HDR=YES', 'select * from [Sheet1$]') AS A;
View 5 Replies
View Related
Aug 2, 2007
I have an excel spreadsheet and I want to transport its data into a table. I have tried copying and pasting but it doesn't work. Any ideas?
View 4 Replies
View Related
Mar 4, 2008
I have a server report which made by ssrs 2005, I am using vs 2005 to build an aspx page and call this report which already uses dynamic query. I use parameters and send these to reportviewer with setparameter method. I dont use DataBind and Refresh method. SetParameter is enough to generate Report. When report generates everything is fine. But when i export this report to excel the pictures in this report get smaller to fit in cell height. I used rendering extensions but its same.
try
{
ReportViewer1.ServerReport.SetParameters(paramList);
//ReportViewer1.ServerReport.Refresh();
//ReportViewer1.DataBind();
}
catch(Exception exc)
{
Response.Write(exc.ToString());
}
And i used copy contents of reportviewer and paste it to excel file. There is interesting case here. If this is the first time that i run the report and copy and paste. No image is seen in excel workseet but other report elements is fine. But if i click on refresh button on reportviewer toolbar and report regenerates, i try to copy and paste and it works fine, and if i dont close ie window copy and paste progress works good and i dont need to click on refresh button on each report to copy and paste?
This is so interesting subject, i tried lots of things for example i tried to use databind and ServerReport.Refresh methods maybe it acts like clicking on refresh button but this wasnt the same only difference is it took more time to generate the report.
Any help?
View 1 Replies
View Related
Aug 9, 2006
Hi, i wanted to know if there is a way that we can know if Sqldatasource retrieved 0 results, i wanted that cause i want to make a condition that if 0 results retrieves a page with the text "No news"...Thanks in advance.
View 2 Replies
View Related
Jan 12, 2006
SQL Server 2000
i have made a table(EmployeeRole) consists of the following fields :
Appname
EmployeeID
RoleID
ProjectID
QMS
1353
1
BI0362
QMS
1353
3
BI0362
QMS
1379
1
BI0362
QMS
1379
13
BI0362and another table called employee
EmployeeID
FirstName
LastName
1353
Wissam
Zein
1379
Wassim
Zeinand another table called Role:
RoleID
RoleName
1
User
3
PD
13
TeamLeaderi need to make a query that gives the following results:
EmployeeID
EmpName
RoleID
RoleName
1353
Wissam Zein
3
PD
1379
Wassin Zein
13
TeamLeader
thank you for the help and for the time
View 5 Replies
View Related
Jan 16, 2001
Can someone give an example on how to insert data into a table that I get from running a any System Stored Procedure.
Thank You,
John
View 2 Replies
View Related