I have user table in my DB. I have 1 excel sheet having list of some users (not all) with changes. How can I Update the values given in excel sheet to my user table? is it possible with import data option?
I only learned this in the past year. You can query an excel sheet as if it's a table. As long as your keys are also in excel you can join the excel sheet to the user table.
You can have a look at this Microsoft Article that discusses options for importing from Excel to SQL Server.
If you are interested, I have built an Excel to SQL Server tool where end users update their data in Excel sheets on the intranet and the application will take care of parsing the Excel spreadsheet and export the data to a SQL Server table.
I'am currently looking for feedback so I give away licenses (two end users) to people who give feedback on the product.
The tool is called SQL Spreads: www.sqlspreads.com
Follow the steps:
Declare @FileFath Varchar(Max)='C:\aa.csv' Declare @Col Varchar(max) Declare @SQL Varchar(max) CREATE TABLE #DTemp (TempColumn VARCHAR(Max)) SET @Sql = 'BULK INSERT #DTemp FROM ''' + @FilePath + ''' WITH ( FIELDTERMINATOR =''\n'', FIRSTROW = 1, ROWTERMINATOR = ''\n'', LASTROW = 1 ) ' Exec (@Sql) SET @COL=SELECT TempColumn FROM #DTemp) SET @Col='(' + REPLACE (@Col,',',' VARCHAR (999) ,') + ' VARCHAR (999),' SET @Sql = 'Create TABLE ##TempTable' + @Col + '' Exec (@Sql) SET @sql='BULK INSERT ##TempTable FROM '''+@FilePath+''' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR =''\n'', TABLOCK )' EXEC(@Sql)
Then Use above table to update the value to main table by joining.