Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 retrieve create view syntax from existing view

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2010-11-21 : 04:00:47
Hello

I'm making a tool to transfer parts of an MS SQL db to a MySql DB
For tables it's already done

But now I have to transfer some view

How can I retrieve the design syntax of existing views ?

Thanks for any help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-21 : 04:04:31
you can script the view out from management studio by right clicking on view and selecting open script as create

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-11-21 : 09:34:34
quote:
Originally posted by olibara

Hello

I'm making a tool to transfer parts of an MS SQL db to a MySql DB
For tables it's already done

But now I have to transfer some view

How can I retrieve the design syntax of existing views ?

Thanks for any help





Out of curiosity does that tool converts MS SQL specific syntax and data types to MySql flavour?

PBUH

Go to Top of Page

olibara
Yak Posting Veteran

94 Posts

Posted - 2010-11-21 : 11:26:51
quote:
Out of curiosity does that tool converts MS SQL specific syntax and data types to MySql flavour?


More or less : I do not have very specific needs but with a little effort it can do it easily for about 95% I think with some shortcut as for currency and other exotic feature
Go to Top of Page

olibara
Yak Posting Veteran

94 Posts

Posted - 2010-11-21 : 11:55:40
quote:
Originally posted by Sachin.Nand
Out of curiosity does that tool converts MS SQL specific syntax and data types to MySql flavour?

PBUH





Hello here is a example of the actual "conversion"

        switch (Type)
{
case "int":
sb.AppendFormat(" {0} int(10) default NULL", ColName);
break;
case "bigint":
sb.AppendFormat(" {0} bigint(10) default NULL", ColName);
break;

case "smalldatetime":
case "datetime":
sb.AppendFormat("{0} DateTime default NULL", ColName);
break;
case "bit":
sb.AppendFormat("{0} bit default NULL", ColName);
break;
case "nvarchar":
case "ntext":
sb.AppendFormat("{0} Varchar({1}) default NULL", ColName,Max);
break;
case "char":
sb.AppendFormat("{0} char({1}) default NULL", ColName,Max);
break;
case "decimal":
sb.AppendFormat("{0} Decimal default NULL", ColName);
break;
case "real":
sb.AppendFormat("{0} real default NULL", ColName);
break;
case "money":
sb.AppendFormat("{0} Decimal default NULL", ColName);
break;
default:
MessageBox.Show("UnKnown : " + Type);
break;
}
Go to Top of Page
   

- Advertisement -