Solved

Create a SQL Table from attached excel template

Posted on 2013-12-17
5
365 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
  • 3
5 Comments
 
LVL 65

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 48

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

My client sends data in an Excel file to me to load them into Staging database. The file contains many sheets that they have same structure. In this article, I would like to share the simple way to load data of multiple sheets by using SSIS.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now