| Author |
Topic |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2012-01-19 : 10:09:27
|
OK..jammed upSSMS Now exports to a file per object with filnames (for sprocs) likedbo.ValidateUser.StoredProcedure.sqlHow do I do a rename to lose dbo. and StoredProcedure. from the filename?Or is there an option in SSMS that I am not aware to just make it sprocname.sql?And yes I inherited this, and the sproc names have very little in the way of naming standardsLike what does ValidateUser Mean...I'm sure it's a SELECT for existenceso I would have done usp_SEL_UserBut we can't just go off renaming thingsSo before I start checking all of these into PVCS, I'd like to rename themOH..and some of the sprocs don't even compileMsg 207, Level 16, State 1, Procedure GetCaseCurrentOwner, Line 19Invalid column name 'StatusId'.Msg 207, Level 16, State 1, Procedure GetCaseCurrentOwner, Line 21Invalid column name 'Id'.Msg 207, Level 16, State 1, Procedure GetCaseDistributionList, Line 35Invalid column name 'IsActive'.Msg 207, Level 16, State 1, Procedure GetCaseDistributionList, Line 57Invalid column name 'IsActive'.Msg 209, Level 16, State 1, Procedure GetSecUsersAccess, Line 21Ambiguous column name 'EffectiveDt'.Msg 209, Level 16, State 1, Procedure GetSecUsersAccess, Line 22Ambiguous column name 'EndDt'.The module 'mntSaveCaseSubType' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveCaseType' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveContactType' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveHairColor' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveLocations' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveQuestion' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveQuestion' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveQuestionEntities' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveRegion' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveSecurityFirms' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveVehicleColors' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveVehicleMake' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.The module 'mntSaveVehicleTypes' depends on the missing object 'UpdateMaintenenceListId'. The module will still be created; however, it cannot run successfully until the object exists.Msg 207, Level 16, State 1, Procedure SaveDistributionList, Line 40Invalid column name 'IsActive'.Msg 207, Level 16, State 1, Procedure SaveDistributionList, Line 45Invalid column name 'IsActive'.Msg 207, Level 16, State 1, Procedure SaveDistributionList, Line 44Invalid column name 'IsActive'.Msg 207, Level 16, State 1, Procedure SaveDistributionList, Line 55Invalid column name 'IsActive'. Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/ |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-01-19 : 11:04:58
|
| Here's some command line magic that might help, run this in your stored procedure directory:for %z in (dbo.*.sql) do @for /F "tokens=2 delims=." %a in ('echo %z') do @echo ren "%z" "%a.sql"This will print out the rename commands, I suggest you look them over VERY CAREFULLY before running them. If they look OK, you can perform the rename with this:for %z in (dbo.*.sql) do @for /F "tokens=2 delims=." %a in ('echo %z') do @ren "%z" "%a.sql"edit: added quote marks |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2012-01-19 : 11:07:35
|
I'll give it a whirlI already did thisCREATE TABLE #Dir(Col1 varchar(max))GOINSERT INTO #Dir(Col1)EXEC master..xp_cmdshell 'dir \\L-LLRLTENN\Public\PSRS\Sprocs\*.*'SELECT CHARINDEX('dbo.',Col1) FROM #DirDECLARE myCursor99 cursorFORSELECT 'RENAME \\L-LLRLTENN\Public\PSRS\Sprocs\' + SUBSTRING(Col1,40,50) + ' ' + SUBSTRING(REPLACE(REPLACE(Col1,'dbo.',''),'.StoredProcedure',''),40,50)FROM #DirWHERE CHARINDEX('dbo.',Col1) <> 0DECLARE @dos varchar(8000)OPEN myCursor99FETCH NEXT FROM myCursor99 INTO @dosWHILE @@FETCH_STATUS = 0 BEGIN EXEC master..xp_cmdshell @dos FETCH NEXT FROM myCursor99 INTO @dos END CLOSE myCursor99DEALLOCATE myCursor99GODROP TABLE #DirGOBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/ |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2012-01-19 : 12:20:24
|
| I usually do:DIR /B *.SQL >MyTempFile.BATThen use a programmers editor (which allows RegEx style Find & Replace) to change each line fromdbo.ValidateUser.StoredProcedure.sqltoREN "dbo.ValidateUser.StoredProcedure.sql" "StoredProcedure.sql"and then run the BATch file. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-01-19 : 18:16:04
|
| Did you try my code at all? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-20 : 10:25:05
|
| erm.If you right click on the database and then go to Tasks -> Generate ScriptsThen you can export everything to the same file, or multiple files as you wish, you can choose to leave the schema off the names or on.....basically, everything I think you want to do????Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2012-01-20 : 10:42:32
|
| "you can choose to leave the schema off the names or on"In the minefield of available options I've never seen that one.Amazes me that there isn't a means of saving the option choices as a "template" for future script-generations ... although maybe there is and I have just never found it ... |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-20 : 10:54:46
|
quote: In the minefield of available options I've never seen that one.
It's in the first dialogue. Under general options "Schema qualify object names" by default it's set to trueYeah -- I can't see a template option either. Which is a pain in the ass.We use redgate source control and sql compare which means we don't really have to bother with the script tasks too often.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2012-01-20 : 10:56:57
|
"Schema qualify object names"Never realised that that would impact the filenames. Ho!Hum! Thanks for that, filed in memory for longer term use |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-01-20 : 11:04:34
|
| That's all well and good until you use Data Dude. I'm sure there's a way to turn off the naming convention it uses, but it's an even bigger pain in the ass, and it's completely incompatible with the scripts you get from SSMS.And if you're wondering why I'd use Data Dude, it's because the app includes the database objects in the project, and it's the only way we're allowed to build. It's actually not too bad, it just suffers from new-kid-on-the-block-and-therefore-I'm-better-than-everyone design mentality. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-20 : 11:10:48
|
| you going to shift when you can do everything from visual studio in 2012?EDIT: Wait, that was what you were talking about right? the stuff that was in the CTP3. Dac packs etc?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION[/red] |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-01-20 : 11:37:29
|
| Nope, I wasn't talking about DAC Packs, just Visual Studio Database Projects. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-20 : 11:38:55
|
| hmmm. I dumped everything to one file at the end.Maybe if you go down the multiple file routes then it just does whatever it pleases.sorry for the misleading info then.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|