SQL Server 2000 - Create An Excel File By Stored Procedure..
Mar 3, 2008Can I create an excel file by stored procedure?
View 2 RepliesCan I create an excel file by stored procedure?
View 2 RepliesHi ;
I am trying to create several Excel sheets using SQL 2000 views like so:
Select * INTO [Excel 8.0;Database="C:spreadSheetsaNew.xls"] FROM [aView].
When I try and execute this in my app I get the following - Specified owner
name 'Excel 8.0;Database=c:spreadSheetsaNew.xls' either does not exist or
you do not have permission to use it.
If I use the above Select statement with an OLEDB connection it works.
I am using Imports System.Data.SqlClient, instantiating a new SQlConnection
object, opening the connection, etc..
Thanks,
Gordon
I have a store procedure in MC400 which I can call from SSMS using the below command:
EXEC ('CALL GETENROLLMENT() ')At serverName
Now this command returns two data sets like:
HA HB HC HD HE
1112
112571ABC14
113574ABC16
114577ABC87
DADBDCDD
1115566VG02
1115566VG02
1115566VG02
I want to generate two different XML files from these two datasets.Is there any way this can be achieved in SSIS or t-sql ?
Anyone have the code used in DTS to make a connection to Excel? Or perhaps a better idea? I need to pass different file names to a stored procedure which would upload the spreadsheet data into SQL7 on demand.
View 1 Replies View RelatedHi there,
Does anyone know any possible way of creating a dbf file from within a stored procedure?
Any guidence, articles, examples, topics to revice would be a great help.
Thanks guys
Butterfly82
I have the following code to import .csv file into my table in excel. It's being inserted into a table. dbo.ImportedPromoPricing. Table and the .csv file have 3 fields price, code and selling price.
Once import is completed I want to use the data in my dbo.ImportedPromoPricing to update another table dbo.MasterPricing. Records need to be compared and updated or appended if needed. in case of update only price will be updated. this is the beginning of my code
USE [Reporting]
GO
/****** Object: StoredProcedure [dbo].[ImportPromoPricing] Script Date: 03/03/2014 14:04:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
[Code] .....
In XSD file keep specification of each tables
So I think It would have some class or method to generate common stored procedure from xsd file.
Please help me.
Is there a way to use BCP or something else within a stored procedure to extract data from a select statement out to a text file?
View 4 Replies View RelatedHi!!!
Is it possible to create a stored procedure which will create a text file (containing information from some tables) and send it via e-mail to a list of user.
I know that I will have to configure the SQL Mail.
If it is possible, can someone give me sample code.
Thanks you.
I created stored procedure to create trigger file in a particular directory using xp_cmdshell.
I am calling the procedure from windows batch script as follows
@@set osq200=osql /a 4096 /b /E /e /d %dbn% /m-1 /r 0 /S %dbs% /Q "exec SP_Create_TriggerFile %2,%1 "
@%osq200% >>%3rec.txt 2>%3rec_err.txt
@set dberr=%errorlevel%
@if %dberr% GTR 0 goto createDATriggerFileErr >>%3rec.txt
If the directory doesn't exist, its throwing error "The system cannot find the path specified" , but the %errorlevel% still showing as 0..
I am trying to import an Excel file - when I pick the file I get the message "Could not open file for reading. Close any other application that may be locking the file."
I have verified that the file is not open - I have even rebooted the machine - still the same message - what am I doing different?
Please advise.
Thanks
Data for Source Column 15 'Notes' is too large for the specified buffer size. How do I get around this, I can see some of the notes entries are beyond 255 chars so I changed the destination datatype to textI have never seen this error when importing before. What do I do?
View 1 Replies View Relatedi want ot import data from excel .xls file to sql server 2000
into an existing table.
should i use some stored procedures or else
Friends
Any one of you share your knowledge how to transfer data from a database to a excel using dts packages in sqlserver 2000.
I want clear steps how to create a dts package
Appreciate your help
Thanks
satish
I need to run a SQL Server 2005 stored procedure by pressing a command button in excel 2003. Basically, I want stored procedures run from Excel to get the view/queries from sql.
Searched and tried many solutions here and in other web resources, read about opening the datasource, but I cannot find the exact solution for my problem.
Any help would be greatly appreciated,
Thanks
Hallo!
I would like to create a backup file in SQP-Server Express and restor this backup-file in SQL-Server 2000.
I am looking for the command that produces the .bak-file.
Thank you very much!
Regards,
Fabian
my favorit hoster is ASPnix : www.aspnix.com !
I am calling a stored procedure (say X) and from that stored procedure (i mean X) i want to call another stored procedure (say Y)asynchoronoulsy. Once stored procedure X is completed then i want to return execution to main program. In background, Stored procedure Y will contiue his work. Please let me know how to do that using SQL Server 2000 and ASP.NET 2.
View 3 Replies View RelatedI need to export data, from within a MSSql stored procedure to excel. Right now we use DTS, but its cumbersome and the users always screw it up.
I would usually just send the tabel to a .csv fiel and pick it up in excel, but I have a field that has preceding zeros and excel truncates them and uses a general fromat.
Any ideas
Thanks
Currently i am using SQL Server 2012 Import/Export Wizard to upload data to sql tables manually. However i was trying to write a procedure to update that table. and on the time of execution, if i can pass excel. Is there any way to pass excel to stored procedure parameter?
View 1 Replies View RelatedYes it looks like a stupid question
but when i right click stored procedures
and click new stored procedure, it gives me a
QRY analyzer style window and all i can do is save
the qry as a regular .qry file ?
I have an excel file that is stored in a sharepoint document library. I am trying to use SSIS to import it into a SQL database. I use the excel connection manager with a sharepoint UNC path. When I run it from BIDS, it runs successfully. When I run it from a job, I get an error
"It is already opened exclusively by another user, or you need permission to view and write its data"
It is definitely not open by anyone else, and I have full permissions to the file. ALSO, the SQL Agent and Service acct which the job runs under, has full permissions to the file. I have tried running it under a proxy account with my user account, but it fails with the same message. Further, I can run a DIR command from a command prompt to list the sharepoint directory contents successfully, but when I run the same command from SSMS using xp_cmdshell, it fails with access denied. Again, the SQL Service acct has full rights to the sharepoint site.
I notice when i browse to the sharepoint document library and try to open the folder with "Open with Windows Explorer", it always asks me to login and I'm thinking that is related to the problem I am having - that it doesn't automatically pick up the windows authentication.
I am trying to create a trigger with in a stored procedure. When I execute the stored procedure I am getting the following error :
Msg 2108, Level 15, State 1, Procedure JPDSAD1, Line 1
Cannot create trigger on 'FRIT_MIP003_BOK_BTCH_LG.P62XB1.XB1PDS' as the target is not in the current database.
Here is the code for the stored procedure :
CREATE PROCEDURE [dbo].[InsertTRIGGER](@databaseA varchar(50))
AS
BEGIN
exec ('USE ['+@databaseA+'];')
exec ('CREATE TRIGGER [P62XB1].[JPDSAD1] ON [' + @databaseA + '].[P62XB1].[XB1PDS] ' +
'AFTER DELETE AS ' +
'BEGIN ' +
' INSERT INTO [' + @databaseA + '].[P62XB1].[XL1TDS] SELECT CAST(SYSDATETIME() AS DATETIME2(6)) , ''B'' , ''D'' , IDA_DELETE ' +
' ''0001-01-01 00:00:00.000000'' , '' '' FROM DELETED ' +
'END')
END
is it possible to create PW on Stored Procedure? No one can execute or Alter any Store Procedure with Password?
View 1 Replies View RelatedI need a script that inserts the data of an excel sheet into a table. If something already exists it should leave it, unless it's edited in the excel sheet and so on and so on. This proces has to go through a stored procedure... ...But how?
View 6 Replies View RelatedI have wrriten many stored procedures in the past without issue, but this is my first time using SQL Server Management Studio Express. I am having trouble creating a new stored procedure. Here is what's happening:
I am opening my database, right clicking on "Stored Procedures" and selecting "New Stored Procedure". A new window opens with a template for creating a stored procedure. The window is called: "SQLEXPRESS.DBName - sqlquery1.sql". I then type up my stored procedure without an issue.
However, when I go to save the stored procedure it wants to save it as a separate file in a projects folder. It does not become part of the DB (as far as I can tell).
When I used to use Enterprise Manager (not an option anymore) this never happened.
I'm sure I'm doing something dumb. Can someone enlighten me.
Thanks,Chris
I have table named TEMPLATE_ACTIVITY. This is template table I have 27 this kind of tables.
I want to create stored procedure to change name MICHELIN_US_ instead of TEMPLATE_ all remaining name should be same. For that I am using 'Create Table As Select' to keep same structure as Template tables.
I want to create sp as like execute this way Exec @MICHELIN_US_
So that in future if Client change to MICHELIN_US_ to UNITED_ I can just change Exec @UNITED_
And it will change all table names to UNITED_ACTIVITY
I want to create this SP for different client.
I have a database which uses "Database Mirroring", and I need to write stored procedure and pull data from "Principal Server".
My Current Logic:
CREATE PROCEDURE abc123
as
BEGIN
IF Server01 = 'ONLINE'
BEGIN
[Code] .....
The problem I am facing is: Stored procedure is not created because "One of the server is not Online"...
Here's my problem:I'm developing an ASP.NET 2.0 application that has a user select one or moreauto manufacturers from a listbox ("lstMakes"). Once they do this, anotherlistbox ("lstModels") should be filled with all matching models made by theselected manufacturers. If lstMakes was not multi-select, I'd have noproblem. But in this case it has to be multi-select. The database is SQLServer 2005 which does not accept arrays as parameters. I've been told thatI have to create an XML document that will act as a filtered Manufacturerstable that I can join to my Models table in my stored procedure. Problem isI don't have the foggiest idea how to do this. I've seen some examples thatjust leave me scratching my head so I was hoping someone could look at whatI'm trying to do and show me how to do this. Thanks!
View 2 Replies View RelatedI am trying to get the DTS Execute SQL task to run a simple sql server 2000no-parameter stored procedure.The procedure runs without error when using SQL Analyzer but DTS Execute SQLreports "could not find stored procedure "[dbo].[test]"The stored procedure is as follows:create procedure test asdeclare tnames_cursor CURSORforselect database_name, tmp_table_name from[DW_Dimensions].[dbo].[vw_dimension_temporary_tables_active]open tnames_cursordeclare @tablename sysnamedeclare @databasename sysnamewhile (@@FETCH_STATUS <> -1)beginselect @databasename = rtrim(@databasename)select @tablename = rtrim(@tablename)exec ("delete from " + @databasename + ".dbo." + @tablename)fetch next from tnames_cursor into @databasename, @tablenameendclose tnames_cursordeallocate tnames_cursorGOAny ideas?
View 1 Replies View RelatedI have a stored procedure that builds a sql statement and executes it. When run in Query Analyzer it runs successfully and displays records as it should. When I open a recordset with the stored procedure from VBA it executes the codes but doesn't open the recordset.
The store procedure is:
ALTER PROCEDURE dbo.spTest
AS
DECLARE @sColumns varchar(2000)
DECLARE @sFrom varchar(2000)
DECLARE @sWhere varchar(2000)
DECLARE @sSqlString AS nvarchar(2000)
SET @sColumns = 'dbo.tblDoctor.lastname '
SET @sFrom = 'FROM dbo.tbldoctor '
SET @sWhere = 'WHERE dbo.tbldoctor.doctorcode is not null '
SET @sSqlString = 'SELECT ' + @scolumns + ' ' + @sFrom + ' ' + @swhere PRINT '@scolumns ' + @scolumns
PRINT '@sfrom ' + @sfrom PRINT '@swhere ' + @swhere PRINT 'sqlstring ' + @sSqlstring
EXEC Sp_executesql @sSqlString
The VBA code is:
Private Sub Command0_Click()
Dim cn As Connection
Dim rs As New ADODB.Recordset
Dim strsql As String
Set cn = CurrentProject.Connection
strsql = "exec spTest"
With rs
.Source = strsql
.ActiveConnection = cn
.CursorType = adOpenKeyset
.LockType = adLockReadOnly
.Open
End With
Debug.Print rs.RecordCount & " records found"
End Sub
When it hits the line with rs.recordcount it displays the following error: "Operation is not allowed when object is closed" referring to the rs recordset never being opened.
Any suggestions?
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
Hi
This is seshu.
Is there any way to find out the last used stored procedure.
Let me know about this one.
I'm using Java to connect to a SQL Server 2000 database. I connect using the Driver Manager with Sun's odbc driver ( sun.jdbc.odbc.JdbcOdbcDriver ) or I can use the jdbc driver provided by Microsoft (com.microsoft.jdbc.sqlserver.SQLServerDriver)
The Java application makes 1 Connection.
Within the database there exists a stored procedure that updates 2 Tables. The tables have a fixed number of rows that get updated continuously by calls to this stored procedure.
The Java application has a thread pool of 15 threads that create 15 CallableStatements (1 per thread) using the same instance of the Connection object.
According the the Microsoft JDBC driver docs, 1 Connection with multiple calls to the Callable statements is how it's supposed to be done. The following is an excerpt from Microsoft's "SQL Server 2000 Driver for JDBC User’s Guide and Reference" (page 86) regarding Connection Managment:
Managing Connections
Connection management is important to application performance. Optimize your application by connecting once and using multiple statement objects, instead of performing multiple connections. Avoid connecting to a data source after establishing an initial connection.
This is precisely what I'm doing, but I do not know if the the stored procedures are being run concurrently, the documentation does not tell me.
So my question: What is happening inside SQL Server 2000?