Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 import data from excel to database use sql query..

Author  Topic 

kumarasari
Starting Member

2 Posts

Posted - 2013-05-25 : 01:02:09
hi,all

i have a excel sheet how to import data to table use sql query

and how to get total records count and excel sheet call dynamically.........


i will try below query...but not getting correct result..pls post query


ALTER PROCEDURE [dbo].[TOTAL2]
(

@FILE_NAME varchar(100),
@total varchar(100) out
)
AS
BEGIN


set @TOTAL ='SELECT COUNT(*) FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',
''Excel 12.0;Database='+@FILE_NAME +';HDR=YES'', ''SELECT * FROM [Sheet1$]'')'



END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-25 : 09:16:10
Where are you executing the string? use EXEC (@SQL) to execute it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -