Buenas, proba con lo siguiente:

Dim odatos = New SqlConnection(Micadena)
odatos.Open()

 ''Modificado
        Dim correr As String = "if not exists (select * from dbo.sysobjects" & _
                                "where id =
object_id(N'[crm_Vista_Campanias]') and " & _
                                "OBJECTPROPERTY(id, N'IsUserTable') = 1)" & _
                                "begin() " & _
                                "CREATE TABLE [dbo].[crm_Vista_Campanias] (" & _
                                "             [IDvista] int NULL," & _
                                "             [idCampania] int NULL" & _
                                "               )" & _
                                "           ON [PRIMARY]" & _
                                "       end "
 ''Fin Modificado

Dim Comando As New SqlClient.SqlCommand(correr.Trim, odatos)
Comando.CommandType = CommandType.Text
Comando.Transaction = myTrans
Comando.ExecuteNonQuery()

2010/9/20 Carlos A. Schroeter <cschroe...@prodytec.com.ar>:
>  Hola Grupo
> Estoy guardando en una variable cada sentencia sql que se encuentra en
> diferentes script, y los ejecuto desde mi aplicacion .NET
> El tema es que algunos provocan la devolucion de error.
> Les paso el ejemplo de uno de los que da error
>
> Dim odatos = New SqlConnection(Micadena)
> odatos.Open()
> Dim correr As String = "if not exists (select * from dbo.sysobjects
>                                        where id =
> object_id(N'[crm_Vista_Campanias]') and
>                                        OBJECTPROPERTY(id, N'IsUserTable') =
> 1)
>                                        begin
>                                            CREATE TABLE
> [dbo].[crm_Vista_Campanias] (
>                                              [IDvista] int NULL,
>                                              [idCampania] int NULL
>                                                )
>                                            ON [PRIMARY]
>                                        end "
> Dim Comando As New SqlClient.SqlCommand(correr.Trim, odatos)
> Comando.CommandType = CommandType.Text
> Comando.Transaction = myTrans
> Comando.ExecuteNonQuery()
>
> El error dice SINTAXIS INCORRECTA ACERCA DE '[crm_Vista_Campanias]'
>
> Creo que son las comillas simples.....alguna idea? otra manera de correr
> script de sql?
> Muchas Gracias
>
> Carlos A. Schroeter
>
>
>



-- 
?

Responder a