Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to auto generate sql query

how to auto generate sql query

Scheduled Pinned Locked Moved Database
databasetutorialquestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    Hey, I am just wondering whelther we can generate the sql query if we already have tables. Just curious about that. If yes, how to do it ??

    suchita

    D C T 3 Replies Last reply
    0
    • D Dhyanga

      Hey, I am just wondering whelther we can generate the sql query if we already have tables. Just curious about that. If yes, how to do it ??

      suchita

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What kind of queries are you looking for? Management Studio 2008 does provides the basic structure of the statements fora table.

      D 1 Reply Last reply
      0
      • D Dhyanga

        Hey, I am just wondering whelther we can generate the sql query if we already have tables. Just curious about that. If yes, how to do it ??

        suchita

        C Offline
        C Offline
        Corporal Agarn
        wrote on last edited by
        #3

        With a little work SQL 2005 and SQL 2008 both have a GUI by right clicking the white space of the query analyzer. Or if you just want one table you can right click the table then click SELECT TOP 1000 Rows

        1 Reply Last reply
        0
        • D dan sh

          What kind of queries are you looking for? Management Studio 2008 does provides the basic structure of the statements fora table.

          D Offline
          D Offline
          Dhyanga
          wrote on last edited by
          #4

          like i created one table. lets say S.N | Name | PhoneNumb| Now this S.N is auto increment. I am testing my project and I need to reset table many times and since this S.N is auto increment, its value just kept on increasing. So what i'm doing is just deleting the table and re-creating the table manually. So i am just wondering that if i can generate the "create" sql query for the already existed table, then once i delete that table, i can re-run that create query to create that table again. Well I can write the query and re-run it. Thats not the problem but i am just checking if there is any that feature in sql server ??

          suchita

          D 1 Reply Last reply
          0
          • D Dhyanga

            like i created one table. lets say S.N | Name | PhoneNumb| Now this S.N is auto increment. I am testing my project and I need to reset table many times and since this S.N is auto increment, its value just kept on increasing. So what i'm doing is just deleting the table and re-creating the table manually. So i am just wondering that if i can generate the "create" sql query for the already existed table, then once i delete that table, i can re-run that create query to create that table again. Well I can write the query and re-run it. Thats not the problem but i am just checking if there is any that feature in sql server ??

            suchita

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            How are you performing the testing? If you are using test projects, make use of TestInitialize and TestCleanUp methods to clean the data up from the tables used.

            D 1 Reply Last reply
            0
            • D dan sh

              How are you performing the testing? If you are using test projects, make use of TestInitialize and TestCleanUp methods to clean the data up from the tables used.

              D Offline
              D Offline
              Dhyanga
              wrote on last edited by
              #6

              I am new to testing. I have just one ascx page and i am testing that page. I saw the example using that in http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testinitializeattribute(VS.80).aspx[^] But I dont know how this links to empty the database tables.. ??

              suchita

              D 1 Reply Last reply
              0
              • D Dhyanga

                I am new to testing. I have just one ascx page and i am testing that page. I saw the example using that in http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testinitializeattribute(VS.80).aspx[^] But I dont know how this links to empty the database tables.. ??

                suchita

                D Offline
                D Offline
                dan sh
                wrote on last edited by
                #7

                Your TestCleanUp method should execute the script to clean the tables from the database.

                D 1 Reply Last reply
                0
                • D dan sh

                  Your TestCleanUp method should execute the script to clean the tables from the database.

                  D Offline
                  D Offline
                  Dhyanga
                  wrote on last edited by
                  #8

                  But I dont know where to use that method. If i am running the aspx page, where should testinitialize method run ?? Do I need to include that in code behind or how does it work ??

                  suchita

                  1 Reply Last reply
                  0
                  • D Dhyanga

                    Hey, I am just wondering whelther we can generate the sql query if we already have tables. Just curious about that. If yes, how to do it ??

                    suchita

                    T Offline
                    T Offline
                    T M Gray
                    wrote on last edited by
                    #9

                    In Management Studio you can right click on any table and choose Script Table As and get a list of choices. If you choose Drop and Create that will give you the script to remove and recreate the table from scratch.

                    D 1 Reply Last reply
                    0
                    • T T M Gray

                      In Management Studio you can right click on any table and choose Script Table As and get a list of choices. If you choose Drop and Create that will give you the script to remove and recreate the table from scratch.

                      D Offline
                      D Offline
                      Dhyanga
                      wrote on last edited by
                      #10

                      Thank you so much. That's exactly what I wanted.

                      suchita

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups