Author |
Topic |
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 02:55:52
|
Annyone know one ? |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 03:20:18
|
Found a way usingsys.master_files |
 |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 03:51:22
|
NEW questionhow do I do this ?set @DBName = @DBName+'string'its inside the same cursor but I want to add something more to the text in the end but the string dosent get added to the variable wenn I use print... annyone have an idea ? |
 |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-10-06 : 04:15:00
|
Can U post your code..? |
 |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 04:20:48
|
My full code is for nowand acturaly I have 2 problem but only posted one.. as number 2 is proberly trivialUSE [LagerTilFlow]GOCREATE TABLE IsBackupNeeded (DBName char(128) PRIMARY KEY, LogningMode char(128) NULL, LogSize char(128) NULL)INSERT INTO IsBackupNeeded (DBName)SELECT name FROM master.dbo.sysdatabases /* Hvis der skal ekskluderes en eller flere Db'erWHERE name NOT IN ('')*/DECLARE @DBName char (128)DECLARE dcur CURSOR LOCAL FAST_FORWARD FOR SELECT DBName from IsBackupNeeded ORDER by DBName OPEN dcur FETCH NEXT FROM dcur INTO @DBName WHILE @@FETCH_STATUS=0BEGIN UPDATE IsBackupNeeded SET LogningMode = (CONVERT(char(128), databasepropertyex(@DBName,'recovery')))WHERE DBName = @DBNameset @DBName = @dbname+'string' <------- PROBLEM START AND END print @DBNameSELECT size FROM sys.master_files <---- PROBLEM startUPDATE IsBackupNeededSET LogSizeWHERE name = @DBName <----- PROBLEM endFETCH NEXT FROM dcur INTO @DBName END CLOSE dcur DEALLOCATE dcur godrop TABLE IsBackupNeeded |
 |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-10-06 : 04:28:42
|
what is the error u have faced |
 |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 04:42:39
|
set @DBName = @DBName+'string'Does not add the +'string' to the variableandSELECT size FROM sys.master_files UPDATE IsBackupNeededSET LogSizeWHERE name = @DBNamegives me the followingMsg 156, Level 15, State 1, Line 4Incorrect syntax near the keyword 'WHERE'. |
 |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-10-06 : 04:56:09
|
is sys.master_files is created by yourself. If Yes please write likeUPDATE tbl1SET LogSize( SELECT size FROM sys.master_files tbl2 Where tbl.key_value = tbl2.keyvalue)From IsBackupNeeded tbl1WHERE name = @DBName |
 |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-10-06 : 04:58:22
|
Sorry SET LogSize = ( SELECT size FROM sys.master_files tbl2 |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-10-06 : 05:01:29
|
You have two options:1. Change the data type of @DBName to varchar(128)2. set @DBName = ltrim(rtrim(@dbname))+'string'Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-10-06 : 05:06:19
|
quote: Originally posted by bkpgamble SELECT size FROM sys.master_files UPDATE IsBackupNeededSET LogSizeWHERE name = @DBNamegives me the followingMsg 156, Level 15, State 1, Line 4Incorrect syntax near the keyword 'WHERE'.
There are two errors here:1. After selecting size column from sys.master_files, you haven't assigned it to any variable2. In UPDATE statement, you haven't provided value for size column of IsBackupNeeded table.Do this:UPDATE IsBackupNeededSET LogSize = (SELECT size FROM sys.master_files where name = @DBName)WHERE name = @DBName orUPDATE bSET LogSize = m.sizeFrom IsBackupNeeded b Join Sys.master_files mon b.name = m.nameWHERE b.name = @DBName Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-10-06 : 05:06:25
|
What version of SQL Server ?dbcc sqlperf(logspace)-------Moo. :) |
 |
|
Kristen
Test
22859 Posts |
|
bkpgamble
Starting Member
30 Posts |
Posted - 2006-10-06 : 05:18:30
|
Thanks all for the response :) I have fixed it nowand Thanks for the link will provide some good reading |
 |
|
|