Friday, February 24, 2012

Insert procedure from Excel

Hi all

I need to create a stored procedure that will insert from an Excel document. And I'm not exaclty sure of how to do that.

CREATE PROCEDURE [Insert_ActiveSuspensions]

AS
INSERT INTO [GamingCommissiondb].[dbo].[License_SuspensionsView]
([TM #],
[FIRSTNAME],
[LASTNAME],
[SS #],
[REASONFORSUSPENSION],
[ENDDATE]
[BEGINDATE])


SELECT
[TM#],
[LASTNAME],
[FIRSTNAME],
[SSN#],
[NOTES],
[DATEOFCONDITIONAL]

FROM "C:\Documents and Settings\Desiree Stevenson\My Documents\TerminationInserts.xls"
IF @.@.Error <> '0'

is this correct??create a linked server to the excel file. look up sp_addlinkedserver in BOL.|||I am wanting to export from a table to an Excel spreadsheet and then to a table in another database.

I should explained that better sorry|||Consider the import/export wizard in Enterprise Manager (SQL 2000) or Management Studio (SQL 2005).|||Try with BCP command......... Google "BCP"......... There is your answer.......

Thanks,
Rahul Jha|||With Excel, make sure SET NOCOUNT ON is specified in the procedure. It causes problems called by an xla.|||Try with BCP command......... Google "BCP"......... There is your answer.......

Thanks,
Rahul Jha

excuse me?

this message...|||I am wanting to export from a table to an Excel spreadsheet and then to a table in another database.

I should explained that better sorry

ummm, why?

is the database on the same server/instance?

No comments:

Post a Comment