Create View in SQL Server from within Delphi

Posted on 2008-11-10
Last Modified: 2013-11-23

How can I create a View in SQL Server from within Delphi?
The connections is done via TADOConnection.

Thanks, Stef
Question by:Delphiwizard
    LVL 60

    Accepted Solution

    so long as you can issue statements against the database and you have permissions to do so, you can create a view

    --this is VB..dont' know delphi

    dim sql as string
    sql = "create view myfiew as select * from mytable"

    connection.execute sql
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    you can run a CREATE VIEW statement like any other DELETE, UPDATE, etc statement using the TADOCOnnection object.
    of course, given the login you use to connect has the right permissions.
    LVL 36

    Expert Comment

    by:Geert Gruwez
    TAdoConnection has a Execute method

    var AdoConnection1: TAdoConnection;

    AdoConnection1Execute('CREATE VIEW AS SELECT * FROM TABLE', cmdText, [eoExecuteNoRecords]);

    Author Closing Comment

    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    In this article I will describe the Copy Database Wizard 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.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    794 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

    16 Experts available now in Live!

    Get 1:1 Help Now