15,890,897 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10689154 (Top 11 by date)
Member 10689154
19-Oct-14 7:07am
View
thanks i have done it
Member 10689154
19-Oct-14 6:51am
View
i think you don't know the answer.
Member 10689154
19-Oct-14 6:46am
View
how i find the maximum value
Member 10689154
13-May-14 4:49am
View
i task manger i see the process id , but i want to see port number that relate to process id.
Member 10689154
12-May-14 13:49pm
View
ok then sql query for that ?
Member 10689154
12-May-14 9:00am
View
data to be inserted
Member 10689154
12-May-14 8:31am
View
i declared variable in column class that i does not used, i remove these variables .
Member 10689154
12-May-14 3:51am
View
it gives an error
Cannot find the object "employee" because it does not exist or you do not have permissions.
Member 10689154
12-May-14 2:59am
View
the above solution 50% help in solving the problem. i solved the problem.
Member 10689154
12-May-14 1:59am
View
i check things but still does not show the column class
Member 10689154
21-Mar-14 14:53pm
View
i found that code. but i does not understand the code.
public string GetTableScript(string TableName, string ConnectionString)
{
string Script = "";
string Sql = "declare @table varchar(100)" + Environment.NewLine +
"set @table = '" + TableName + "' " + Environment.NewLine +
//"-- set table name here" +
"declare @sql table(s varchar(1000), id int identity)" + Environment.NewLine +
" " + Environment.NewLine +
//"-- create statement" +
"insert into @sql(s) values ('create table [' + @table + '] (')" + Environment.NewLine +
" " + Environment.NewLine +
//"-- column list" +
"insert into @sql(s)" + Environment.NewLine +
"select " + Environment.NewLine +
" ' ['+column_name+'] ' + " + Environment.NewLine +
" data_type + coalesce('('+cast(character_maximum_length as varchar)+')','') +
' ' +" + Environment.NewLine +
" case when exists ( " + Environment.NewLine +
" select id from syscolumns" + Environment.NewLine +
" where object_name(id)=@table" + Environment.NewLine +
" and name=column_name" + Environment.NewLine +
" and columnproperty(id,name,'IsIdentity') = 1 " + Environment.NewLine +
" ) then" + Environment.NewLine +
" 'IDENTITY(' + " + Environment.NewLine +
" cast(ident_seed(@table) as varchar) + ',' + " + Environment.NewLine +
" cast(ident_incr(@table) as varchar) + ')'" + Environment.NewLine +
" else ''" + Environment.NewLine +
" end + ' ' +" + Environment.NewLine +
" ( case when IS_NULLABLE = 'No' then 'NOT ' else '' end ) + 'NULL ' + " + Environment.NewLine +
" coalesce('DEFAULT '+COLUMN_DEFAULT,'') + ','" + Environment.NewLine +
" " + Environment.NewLine +
" from information_schema.columns where table_name = @table" + Environment.NewLine +
" order by ordinal_position" + Environment.NewLine +
" " + Environment.NewLine +
//"-- primary key" +
"declare @pkname varchar(100)" + Environment.NewLine +
"select @pkname = constraint_name from information_schema.table_constraints" + Environment.NewLine +
"where table_name = @table and constraint_type='PRIMARY KEY'" + Environment.NewLine +
" " + Environment.NewLine +
"if ( @pkname is not null ) begin" + Environment.NewLine +
" insert into @sql(s) values(' PRIMARY KEY (')" + Environment.NewLine +
" insert into @sql(s)" + Environment.NewLine +
" select ' ['+COLUMN_NAME+'],' from information_schema.key_column_usage" + Environment.NewLine +
" where constraint_name = @pkname" + Environment.NewLine +
" order by ordinal_position" + Environment.NewLine +
//" -- remove trailing comma" +
" update @sql set s=left(s,len(s)-1) where id=@@identity" + Environment.NewLine +
" insert into @sql(s) values (' )')" + Environment.NewLine +
"end" + Environment.NewLine +
"else begin" + Environment.NewLine +
//" -- remove trailing comma" +
" update @sql set s=left(s,len(s)-1) where id=@@identity" + Environment.NewLine +
"end" + Environment.NewLine +
" " + Environment.NewLine +
"-- closing bracket" + Environment.NewLine +
"insert into @sql(s) values( ')' )" + Environment.NewLine +
" " + Environment.NewLine +
//"-- result!" +
"select s from @sql order by id";
DataTable dt = GetTableData(Sql, ConnectionString);
foreach (DataRow row in dt.Rows)
{
Script += row[0].ToString() + Environment.NewLine;
}
return Script;
}
Show More