views:

126

answers:

2

Hi all,

How to retrieve create statement for table from db in C#?

I need to create a script file containing create statement for an existing table in db using C#.

I can generate create statement of storedproc using sp_helptext but can't generate it for table.

Please help.

+1  A: 

It's not supported for tables although a quick google gives a script

http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/28eeb603-1607-4b56-9461-3c0502cbec9c

John Nolan
+2  A: 

this is joke.

  1. use sqlmetal.exe and compile output.
  2. use DataContext.CreateDatabase (use Log property of DataContext to get SQL Code)
kazuk
can't understand your answer.
Himadri
kazuk