Running custom T-SQL Scripts

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
7/18/2011 9:18:35 PM
Gravatar
Total Posts 33

Running custom T-SQL Scripts

Joe,

As part of setting up a new website we want to run t-sql scripts to create few custom tables and stored procedures. There is no associated feature but just running the SQL scripts during the installation Tried to create a dummy folder as below and embedded sql script in the config file as below

setup\applications\dummyfeaturename\SchemaInstallScripts\mssql\0.0.0.1.config

but this doesn't seem to create the tables and stored process.

Can you help us point the right way of doing this.

This situation may not be just during the first installation but could also be post installation. Some thing like we re-run the setup and install the scripts on existing mojoportal site to create the custom tables and stored procs.

 

7/21/2011 12:26:23 AM
Gravatar
Total Posts 355

Re: Running custom T-SQL Scripts

Naveen,

I've just done a test scenario as you've described, and it's working exactly as expected. When you're re-running [yourmojosite]/setup/default.aspx, does your extra script show up as seen here?

Test Screenshot

7/21/2011 7:18:25 PM
Gravatar
Total Posts 33

Re: Running custom T-SQL Scripts

Thanks I see it going through setup process. but now there is a different exception in running the T-script itself. The sql script gets initiated by setup however it complains that there is error in running the script while probably creating the table or inserting data.  Where as the same script when I run on sql server 2008 it runs flawlessly and creates the tables, stored procs and inserts initial records.

Is there something we need to take special precautions while embedding the t-sql script in the mojoportal setup config file?

The way I got the T-sql script created was through using the option generate script wizard in sql server 2008.

Any pointers are appreciated.

7/21/2011 7:36:26 PM
Gravatar
Total Posts 355

Re: Running custom T-SQL Scripts

If you'd like to share the error msg., it would help with diagnosing the exact nature of why the script isn't running correctly.  Does your script have the standard "if it's already there, don't try to re-create it" segment?

7/22/2011 7:06:30 AM
Gravatar
Total Posts 33

Re: Running custom T-SQL Scripts

Below given is the error message:

Running script deals - 0.0.0.5 - 00:00:03.8378460
System.Data.SqlClient.SqlException (0x80131904): Unclosed quotation mark after the character string ''. Incorrect syntax near ''. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at mojoPortal.Data.SqlHelper.ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, String commandText, Int32 commandTimeout, SqlParameter[] commandParameters) in C:\mojoportal\source\mojoPortal.Data.MSSQL\SqlHelper.cs:line 154 at mojoPortal.Data.SqlHelper.ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, String commandText, SqlParameter[] commandParameters) in C:\mojoportal\mojo\source\mojoPortal.Data.MSSQL\SqlHelper.cs:line 113 at mojoPortal.Data.DBPortal.DatabaseHelperRunScript(String script, String overrideConnectionInfo) in C:\mojoportal\source\mojoPortal.Data.MSSQL\dbPortal.cs:line 711 at mojoPortal.Data.DBPortal.DatabaseHelperRunScript(FileInfo scriptFile, String overrideConnectionInfo) in C:\mojoportal\source\mojoPortal.Data.MSSQL\dbPortal.cs:line 644 at mojoPortal.Business.DatabaseHelper.RunScript(Guid applicationId, FileInfo scriptFile, String overrideConnectionInfo) in C:\mojoportal\source\mojoPortal.Business\DatabaseHelper.cs:line 327 - 00:00:04.5242900

 

Also I am surprised to see the local development file path 

"C:\mojoportal\source\mojoPortal.Data.MSSQL\dbPortal.cs"

in the error msg when it is already deployed on the server

 

7/22/2011 12:07:57 PM
Gravatar
Total Posts 18439

Re: Running custom T-SQL Scripts

Can you post your sql? It says there is a missing quote.

7/22/2011 12:38:26 PM
Gravatar
Total Posts 355

Re: Running custom T-SQL Scripts

As Joe mentioned, it would help to see your SQL - it sounds like a single/double-quote mixup.

Something else; if you're running your test script on a host server, have you confirmed where your connection string is pointed?

8/3/2011 12:06:10 PM
Gravatar
Total Posts 33

Re: Running custom T-SQL Scripts

Never mind. Got it working. Looks like there was an issue with identity setting and also a select statement. So what I did was to go through each one of the sql statements and resolved the issue.

Thanks anyway.

You must sign in to post in the forums. This thread is closed to new posts.