Friday, September 27, 2013

[SQL Server] Display Multiple Fields in Case

[SQL Server] Display Multiple Fields in Case


Display Multiple Fields in Case

Posted: 27 Sep 2013 04:23 AM PDT

How can I display multiple fields in Case statement.If I use a "," , it gives an error...Declare @DateInput as Date = '2012-06-10' Select Case when @DateInput between '2012-06-06' and '2013-06-10'then AnniversaryStartDate,AnniversaryEndDateElse NullEnd from dbo.AnniversaryDatawhere DateInput = @DateInput Error Incorrect syntax near ','.

calculate database size

Posted: 27 Sep 2013 06:29 AM PDT

Friends,how can i calculate database size with this information:Processed 8192240 pages for database 'DBOLTP', file 'rm' on file 1. ??(8192240 *8) = 65537920 (bytes) / 1024 / 1024 = 62MB?Thanks...

Jobs to do after restoring 2000 db to 2008 R2

Posted: 26 Sep 2013 09:52 PM PDT

Hi - I'd appreciate a sanity check to a list of jobs I intend to do after a restore of a 2000 db to a new 2008r2 server.1. restore 2000 db using Redgate Backup to new 2008r22. change compatibility level to 20083. set appropriate database file sizes/autogrowth/max size settings4. [url=http://sqlserverplanet.com/dba/using-dbcc-updateusage]run DBCC UPDATEUSAGE[/url][url=http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html]5. run ola hallengren's 'Index and Statistics Maintenance' script for the user db's[/url][url=http://ola.hallengren.com/sql-server-integrity-check.html]6. run ola hallengren's 'Integrity check' script for the user & system db's[/url]I'm not sure if I should run the DBCC updateusage before or after the index & statistics job -I found this article [url=http://sqlserverplanet.com/dba/using-dbcc-updateusage] http://sqlserverplanet.com/dba/using-dbcc-updateusage[/url] which suggests that the statistics should be updated BEFORE running the updateusage - does it matter?any other tips would be greatly appreciated...many thanks...

Executing a SP within a SP with Params. Syntax check

Posted: 27 Sep 2013 01:29 AM PDT

Hey guys - I'm building a SP that essentially fires of a series of other SPs which load data into tables. Since it's early in the development and I test over and over and over, I'd like to limit (duh) the test results to QTYs I determine at the time instead of hundreds of thousands of records with each test. So...I've been manually updating all the SELECT/ INSERT statements to only include records X to Y.I'm trying to have this master SP prompt me for the range of records to test and then pass those same two values to other SPs needing them. Should be very easy but I'm tripping over syntax.Here's my "master" SP.[font="Courier New"]ALTER PROCEDURE [dbo].[sp_00_BigRedButton] @StartPoint int,@EndPoint intASBEGINEXEC sp_1_DumpTestDataEXEC sp_2_InsertOwnersFromOnboardEXEC sp_3_CleanUpOwnerNamesEXEC sp_4_InsertSalesPersonsEND[/font]SPs #2 and #4 are expecting these two values as well. How can I pass these params to those SPs as well. Something like...[font="Courier New"]EXEC sp_2_InsertOwnersFromOnboard(@StartPoint, @EndPoint)[/font]Right??

No comments:

Post a Comment

Search This Blog