Results 1 to 5 of 5

Thread: SQL SERVER - Creating VIEW: displaying error

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    SQL SERVER - Creating VIEW: displaying error

    Friends.

    Greetings.

    I am creating a view in SQL SERVER MANAGEMENT STUDIO 2008 EXPRESS using the following query which I copied from MS-ACCESS.
    -------------------------------------
    SELECT id, Cust_ID, id AS Expr1, Cust_Name, Rm, CDate(InDate & [ ] & InTime) AS InDateTime, SrvcID, InDate, InTime, InRcrdDate, InRcrdTime, SizeName,
    HalaName, LocName, Qty, OutTime, OutDate, OutIqama, Days, CntNo, ExitTime, Deleted, NoCntNo, NoSize, NoHala, NoQty, OutNoCntNo,
    DAMAGES_ID_1, DAMAGES_ID_2, DAMAGES_ID_3, DAMAGES_REMARKS, ISO_CODE, VESSEL_IN, VESSEL_OUT, VOYAGE_IN, VOYAGE_OUT,
    SHIPPING_LINE_CODE, ETA_IN, Rem, ETA_OUT
    FROM dbo.Daily
    -------------------------------------

    But unfortunately I am getting an error that "CDATE function in not an Inbuilt function".

    Guys my task is to migrate the Access Database(including many tables and views)to SQL SERVER.

    I was able to migrate everything, but the ACCESS Views are also migrated as an SQL Table.

    So now I am manually creating the VIEWS in SQL.

    It will be highly appreciable that if u could suggest me any ideas to migrate all the ACCESS QUERIES to SQL VIEWS.
    or else Please help me with an alternate for CDATE() in SQL.

    Thank You.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: SQL SERVER - Creating VIEW: displaying error

    If InDate and InTime are both a datetime field you can just add them ( the Indate + InTime). If both are textfields (varchar,nchar,....) you can do cast (Indate + ' ' + InTime as datetime)
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL SERVER - Creating VIEW: displaying error

    This syntax

    CDate(InDate & [ ] & InTime)

    has a couple of issues.

    First the & is not used in MS SQL to concatenate strings - use plus.

    If both InDate and InTime are "varchar" type fields then do this

    Code:
    Cast(InDate + ' ' + InTime as datetime)

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: SQL SERVER - Creating VIEW: displaying error

    This question has absolutely nothing to do with C#. It is purely a T-SQL question and, as such, belongs in the Database Development forum. I have asked the mods to move it there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: SQL SERVER - Creating VIEW: displaying error

    Thank you for the report jmcilhinney, I have moved this thread to the Database Development Forum.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width