Author |
Topic |
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 08:22:07
|
[code]CREATE TABLE #Info ( DbName SYSNAME, ROUTINE_TYPE SYSNAME, ROUTINE_NAME SYSNAME, Lines INT )EXEC sp_msforeachdb ' INSERT #Info ( DbName, ROUTINE_TYPE, ROUTINE_NAME, Lines ) SELECT ''?'', d.ROUTINE_TYPE, d.ROUTINE_NAME, SUM(CASE WHEN d.c10 < d.c13 THEN d.c13 ELSE d.c10 END) FROM ( SELECT ROUTINE_TYPE, ROUTINE_NAME, 1 + LEN(ROUTINE_DEFINITION) - LEN(REPLACE(ROUTINE_DEFINITION, CHAR(13), '''')) AS c13, 1 + LEN(ROUTINE_DEFINITION) - LEN(REPLACE(ROUTINE_DEFINITION, CHAR(10), '''')) AS c10 FROM .INFORMATION_SCHEMA.ROUTINES ) AS d GROUP BY d.ROUTINE_TYPE, d.ROUTINE_NAME 'SELECT DbName, ROUTINE_TYPE, ROUTINE_NAME, LinesFROM #InfoORDER BY DbName, ROUTINE_TYPE, ROUTINE_NAMEDROP TABLE #Info[/code] E 12°55'05.25"N 56°04'39.16" |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-06-13 : 09:53:06
|
On Sql server 2000...Msg 1540, Level 16, State 1, Line 2Cannot sort a row of size 8106, which is greater than the allowable maximum of 8094.This Peculiar to me?-------------Charlie |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-13 : 10:45:16
|
Peso it gives 1 more than actual number of lines. Also I remember now that once I used the following for the same purposecreate table #myscript_table (sptext varchar(8000))insert into #myscript_table(sptext)EXEC sp_helptext myspselect count(*) from #myscript_tabledelete from #myscript_table MadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 12:26:04
|
I think it calculates the right number of rows.If you have no Cr or Lf, there is only one line of code.If you have 1 Cr or 1 Lf, there is only two lines of code. E 12°55'05.25"N 56°04'39.16" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-13 : 13:13:38
|
Can you create this and see?create procedure myspasselect 1union all--select 2 It has only 6 linesMadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 13:42:12
|
[code]DbName ROUTINE_TYPE ROUTINE_NAME LinesTest PROCEDURE isp_ALTER_INDEX 117Test PROCEDURE mysp 6Test PROCEDURE sp_alterdiagram 65[/code] E 12°55'05.25"N 56°04'39.16" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 13:50:32
|
Still under test database E 12°55'05.25"N 56°04'39.16" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 14:17:05
|
Probably with isp_AlterIndex when finished testing. E 12°55'05.25"N 56°04'39.16" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-13 : 14:19:11
|
So you aren't currently doing any defragmentation? We see major performance problems if we don't do it at least weekly. On some systems, we have to do it daily. We've got so much data pumping into the system, that the indexes become fragmented quickly. Anyway, sorry to hijack the thread. Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 14:26:54
|
We use DBCC today once a week. Scheduled with a job.The largest table where I work today has 50 million records, with an average growth of 60000 records daily, so weekly defrag is ok.My main concern is that for one customer, there is 70% dynamic sql in whole database.So a SP can execute differently according to input parameters for each execution.And the DBA is constantly shrinking both database and log at least twice a week. E 12°55'05.25"N 56°04'39.16" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-13 : 15:08:42
|
quote: Originally posted by Peso
DbName ROUTINE_TYPE ROUTINE_NAME LinesTest PROCEDURE isp_ALTER_INDEX 117Test PROCEDURE mysp 6Test PROCEDURE sp_alterdiagram 65 E 12°55'05.25"N 56°04'39.16"
Well. Again a behavioural changeIt gives me 7 in SQL Server 2000 Developer EditionMadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 15:27:27
|
Run this example to verify.Please notice the placement of single quotesdeclare @a varchar(8000), @b varchar(8000)set @a = 'create procedure myspasselect 1union all--select 2'select datalength(@a), len(@a), LEN(replace(@a, char(10), '')), LEN(replace(@a, char(13), '')), len(@a) - LEN(replace(@a, char(13), '')) + 1 set @b = 'create procedure myspasselect 1union all--select 2'select datalength(@b), len(@b), LEN(replace(@b, char(10), '')), LEN(replace(@b, char(13), '')), len(@b) - LEN(replace(@b, char(13), '')) + 1 E 12°55'05.25"N 56°04'39.16" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 15:28:31
|
I get 6 for @a, and 7 for @b. E 12°55'05.25"N 56°04'39.16" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-13 : 16:02:19
|
quote: Originally posted by Peso I get 6 for @a, and 7 for @b. E 12°55'05.25"N 56°04'39.16"
Yes it is.But still I get one more than actual number when I execute your codeThe sample sp is what you have assigned in @aMy code result ----------- 6(1 row(s) affected) Your code resultDbName ROUTINE_TYPE ROUTINE_NAME Lines -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ----------- test PROCEDURE mysp 7master PROCEDURE mysp 7model PROCEDURE mysp 7msdb PROCEDURE mysp 7Northwind PROCEDURE mysp 7pubs PROCEDURE mysp 7tempdb PROCEDURE mysp 7(7 row(s) affected) MadhivananFailing to plan is Planning to fail |
|
|
|