Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Table Formula SQL 2008

Posted on 2014-02-24
3
Medium Priority
?
186 Views
Last Modified: 2014-03-04
In the design of a table in SQL 2008 there is the ability to add a function to a column of data as its loaded. I have a date column (data type is date) and I want to subtract a day from the date column source file (which is excel). I thought I could simply use a Data Add function of DateAdd(day, -1, Date). However when I insert that and try to save the table I it states that it is an error.
Please advise, thanks
0
Comment
Question by:SeTech
[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
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 39882236
Please post your SQL and the error you get.
0
 

Author Comment

by:SeTech
ID: 39882243
code: DateAdd (day, -1, Date)

Statement: "Error validating the formula for Column Date"
0
 
LVL 12

Accepted Solution

by:
Harish Varghese earned 2000 total points
ID: 39882289
Are you talking about computed column in table? If so, you cannot refer to same column in a computed column expression. For example, below code would work:
CREATE Table RightTable (ID int,
    OriginalDate date,
    ComputedDate as DateAdd(dd, -1, OriginalDate)
)

but below definition will not work:
CREATE Table WrongTable (ID int,
    OriginalDate date,
    ComputedDate as DateAdd(dd, -1, ComputedDate)
)

-Harish
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

598 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