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
  1. Home
  2. Web Development
  3. ASP.NET
  4. SQL Script Generation

SQL Script Generation

Scheduled Pinned Locked Moved ASP.NET
databasetoolssql-serversysadmin
6 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.
  • T Offline
    T Offline
    Tiger456
    wrote on last edited by
    #1

    Hai I am using SQl Server. in Which i Create a table Where Some of the Fields and set with default values. + When i try to generate SQL script using Enterprise manager(Database>All Task>>Generate SQL Script) . i didnt get Sql Script for default value and Some Constrants. Is there any way to generate the Script. + In one of my Table i Preset with some data . Is there any way to generate Insert SQL Script. if these things are not done by Enterprise manage. please suggest me some third party utility. Thanks & Regards

    E S 2 Replies Last reply
    0
    • T Tiger456

      Hai I am using SQl Server. in Which i Create a table Where Some of the Fields and set with default values. + When i try to generate SQL script using Enterprise manager(Database>All Task>>Generate SQL Script) . i didnt get Sql Script for default value and Some Constrants. Is there any way to generate the Script. + In one of my Table i Preset with some data . Is there any way to generate Insert SQL Script. if these things are not done by Enterprise manage. please suggest me some third party utility. Thanks & Regards

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      hi there, actually, SQL Enterprise Manager supports this (because I already did this before). But now I cannot remember exactly. Database>All Task>>Generate SQL Script, Maybe in the Options tab, there is a checkbox for this feature... Hope this helps. << >>

      T 1 Reply Last reply
      0
      • T Tiger456

        Hai I am using SQl Server. in Which i Create a table Where Some of the Fields and set with default values. + When i try to generate SQL script using Enterprise manager(Database>All Task>>Generate SQL Script) . i didnt get Sql Script for default value and Some Constrants. Is there any way to generate the Script. + In one of my Table i Preset with some data . Is there any way to generate Insert SQL Script. if these things are not done by Enterprise manage. please suggest me some third party utility. Thanks & Regards

        S Offline
        S Offline
        Shawn_H
        wrote on last edited by
        #3

        Hai IT should add them if you go to options tab, the check the box for SCript Primary Keys, foreighn Keys, defaults, and check constraints....If you did in fact set the default when you created your table. If you didnt already create your table then you do it through code by hand like this You would Use the DEFAULT Keyword like this in your create statement....this gives the Column named MyName a default value of 'Im Nameless' CREATE TABLE dbo.TempTable ( Tempid INT NOT NULL PRIMARY KEY, MyName VARCHAR(30) NOT NULL DEFAULT 'Im Nameless' ) And Maybe, in case I didnt read your question right, if you are saying because you already have created the default values and you are not getting these Default constraints in the output script, then you could always go into the create script and add an ALTER statement ALTER TABLE dbo.TempTable ADD CONSTRAINT def_My_Name DEFAULT 'Im Nameless' FOR MyName Dont know if this is what you are looking for or not

        T 1 Reply Last reply
        0
        • E enjoycrack

          hi there, actually, SQL Enterprise Manager supports this (because I already did this before). But now I cannot remember exactly. Database>All Task>>Generate SQL Script, Maybe in the Options tab, there is a checkbox for this feature... Hope this helps. << >>

          T Offline
          T Offline
          Tiger456
          wrote on last edited by
          #4

          Thanks:)

          1 Reply Last reply
          0
          • S Shawn_H

            Hai IT should add them if you go to options tab, the check the box for SCript Primary Keys, foreighn Keys, defaults, and check constraints....If you did in fact set the default when you created your table. If you didnt already create your table then you do it through code by hand like this You would Use the DEFAULT Keyword like this in your create statement....this gives the Column named MyName a default value of 'Im Nameless' CREATE TABLE dbo.TempTable ( Tempid INT NOT NULL PRIMARY KEY, MyName VARCHAR(30) NOT NULL DEFAULT 'Im Nameless' ) And Maybe, in case I didnt read your question right, if you are saying because you already have created the default values and you are not getting these Default constraints in the output script, then you could always go into the create script and add an ALTER statement ALTER TABLE dbo.TempTable ADD CONSTRAINT def_My_Name DEFAULT 'Im Nameless' FOR MyName Dont know if this is what you are looking for or not

            T Offline
            T Offline
            Tiger456
            wrote on last edited by
            #5

            Thanks for the Reply 1. Creating default Value Script is solved by turning on the options Is there any way to Create Insert SQL Script Thanks and regards

            A 1 Reply Last reply
            0
            • T Tiger456

              Thanks for the Reply 1. Creating default Value Script is solved by turning on the options Is there any way to Create Insert SQL Script Thanks and regards

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              anig1234, You would probably be better served with this post in the SQL section, but maybe this will help. I dont think MS SQL Server will allow you to do what you are trying to do...correct me if I'm wrong experts....but it can be done through a work around if you really need the insert statements in a script which can be run from query analyzer. First I would check and see if DTS, BCP, or BULK INSERT can solve your problem, you can export to a text file (a CSV list), and then bulk copy from the text file. But in order to do what you are trying to do you'll probably have to write a script that pulls the data and writes a series of Insert statements to a text file...Im no expert on SQL Server though, a program called MySQL Front does exactly what you are looking for with MySQL..... Hope that helps Shawn

              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