SQL Script Generation
-
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
-
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
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. << >>
-
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
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
-
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. << >>
-
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
-
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
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