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.
Author |
Topic |
amsqlguy
Yak Posting Veteran
89 Posts |
Posted - 2011-06-03 : 11:36:22
|
Guys,I am trying to use SQLCMD to run the scripts, however I am facing couple issues 1. The log file generated is not working for mass update where 1mill rows are updated i.e the entry is not being registered in the log file The test.log from the below shows 2 entries corresponding to the 2 insert statements from the test.sql file, however the update statement which effected > 1 mill rows is not getting logged even though the update completed successfully2. How do we make to print the statement with corresponding result in the log file as supposed to only the result. From below example the current test.log output is (1 rows affected) (1 rows affected) Can it be changed to incorporate corresponding command in the log file INSERT INTO TEST (ID) VALUES (1) (1 rows affected) INSERT INTO TEST (ID) VALUES (2) (1 rows affected) DECLARE @cmd varchar(2000)SET @CMD = 'SQLcmd -S SQLINSTANCE -U build_user -P @ccess4U -d TEST -i "\\MC\shares\test.sql" -W >> \\MC\shares\test.log'EXEC master.dbo.xp_cmdShell @cmdTEST.SQLupdate [test1mill]set date_time_mod = getdate()goSET IDENTITY_INSERT TEST ONGOINSERT INTO TEST (ID) VALUES (1)GOINSERT INTO TEST (ID) VALUES (2)GOSET IDENTITY_INSERT TEST OFFGOSET NOCOUNT OFFTEST.LOG(1 rows affected)(1 rows affected)Any suggestions/inputs would help.Thanks |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2011-06-03 : 13:26:28
|
have you tried it with a PRINT statment . e.g in you sql script , place PRINT 'INSERT INTO TEST (ID) VALUES (1)' at the relevant place. Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
|
|