x

TSQL QUERY

Hi Experts ,My developer write below TSQL query and asked me to review it . what steps should i take ?and how i do i test it ?

 BEGIN
     INSERT INTO nsConfig (MachineName, PropertyName, PropertyValue) 
         VALUES ('*', 'PurgeDocumentsBatchSize', '1000');
 END
 
     IF NOT EXISTS(
         SELECT * FROM sys.schemas s 
         INNER JOIN sys.tables t ON s.schema_id = t.schema_id
         INNER JOIN sys.columns c ON t.object_id = c.object_id
         WHERE s.name = 'dbo' AND t.name = 'nsTransactionProperties' AND c.name = 'ToBePurgedDate'
     )
     BEGIN
         ALTER TABLE nsTransactionProperties ADD ToBePurgedDate DATETIME NULL;
     END
 
     IF NOT EXISTS(
         SELECT * FROM sys.schemas s 
         INNER JOIN sys.tables t ON s.schema_id = t.schema_id
         INNER JOIN sys.columns c ON t.object_id = c.object_id
         WHERE s.name = 'dbo' AND t.name = 'nsPDFDocument' AND c.name = 'PurgedDocumentHash'
     )
     BEGIN
         ALTER TABLE nsPDFDocument ADD PurgedDocumentHash VARBINARY(MAX) NULL;
     END
 END


thanks

more ▼

asked Feb 13 at 10:01 PM in Default

avatar image

shamim007
150 5

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You will need to sit down with the developer and understand the purpose of this script. What is the intention? The project requirement? If you understand those, you will know how you should review and approve it if you think the script is fine, or reject and send back for rework if there is a better way to go about the requirement.

Testing should be done first on a local/development environment and see its results. If passed, promote it to higher environments.

more ▼

answered Feb 15 at 12:57 PM

avatar image

nidheesh.r.pillai
9.3k 20 57 49

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2125
x402

asked: Feb 13 at 10:01 PM

Seen: 28 times

Last Updated: Feb 15 at 02:26 PM

Copyright 2016 Redgate Software. Privacy Policy