SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 import data from excel to database use sql query..
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kumarasari
Starting Member

India
2 Posts

Posted - 05/25/2013 :  01:02:09  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 05/25/2013 :  09:16:10  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000