Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQLCMD and inserting data Expand / Collapse
Author
Message
Posted Tuesday, July 9, 2013 7:58 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 11:33 AM
Points: 163, Visits: 562
I am not that familiar with SQLCMD. I am calling a main script which in turn calls other script files. All the other scripts work fine but I am having a problem with only one. In this script I am inserting data into three tables that do have foreign constraints between them. I have no problem running the script in a query window of SSMS when I first drop the constraints, then insert the data, and then add the constraints back. However, when I call the file form the main script it fails with foreign constraint errors. I don't understand why the contents in the file wouldn't be handled in the same way it is when run through SSMS? It is driving me nuts. The worse part is my manager did run it shortly before I got there - i started a week long project leading up to the deployment of their website - and now the thing doesn't work, and I look like the one who broke it. This one file is just many that process the same way. First the tables are created, then the constraints are added, and then data is inserted. Has anyone have any idea what maybe causing the problem?






A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1471917
Posted Wednesday, July 10, 2013 12:15 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 11:33 AM
Points: 163, Visits: 562
Nevermind, I got it working. I was missing a GO batch command after the statement.






A clever person solves a problem. A wise person avoids it.
A clever person solves a problem. A wise person avoids it.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Post #1472289
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse