Solved

Create a SQL Table from attached excel template

Posted on 2013-12-17
5
375 Views
Last Modified: 2016-02-10
I would like to create a simple SQL 2012 table structure with default settings based on a static excel template, the only field that will ever change is the 'Current Date' :- see below snapshot and attached excel sheet.

12-17-2013-4-40-54-PM.gifHourTrack3.xls
0
Comment
Question by:John-S Pretorius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39725404
The SSIS wizard answer is...
Go into SQL Server SSMS
Identify the database where you wish to import the Excel spreadsheet data, and click.
Right-click > Tasks > Import Data..., and follow the prompts
0
 

Author Comment

by:John-S Pretorius
ID: 39725419
Thank you, this part seems pretty straight forward - I have one field in excel that's the actual true currentdate - is there a way that I can script the SQL to change accordingly ?
0
 

Author Comment

by:John-S Pretorius
ID: 39725435
Also is there any way the highlighted changed can now be made to SQL : See below

SQL
0
 
LVL 49

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 39725905
You do not need to store the "current date" in the table at all.

Why not simply create a view, like this

create MyView as
select
Intervals, TimeToSec, Fraction, Time, Time_Hours, convert(date,getdate()) as CurrentDate
from MyTable

then you would use "MyView" instead of "MyTable" in subsequent SQL code, e.g.

select d.*, MyView.CurrentDate
from SomeDataTable as d
inner join MyView on d.intervals = MyView.intervals


NB: above I suggested:
 convert(date, getdate() ) as CurrentDate

If you need a datetime column instead of date then do this:

 convert(datetime, convert(date, getdate() ) ) as CurrentDate
0
 

Author Closing Comment

by:John-S Pretorius
ID: 39726686
Thank you - your assistance got me what I needed.
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question