Viking’s Weblog

October 28, 2009

Ctrl+Shift+M – SQL template

Filed under: Tips & Tricks — msrviking @ 10:53 PM

I was doing a regular reading through my favorite blogs and I learnt something new early in the morning. Here is what it is all about.

Being on development side of the applications I always recommend developers, leads and everyone who wants to write t-sql code to use standard templates. How could we achieve this quickly?

On opening your SSMS instead of a blank window, you could get your template by using Ctrl+Shift+M, and you could customize your template by replacing the content in the file or replacing the file itself but with same name in the following path

C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql

The file you will want to edit to standardize the template will be Sqlfile.SQL.

I got this tip from my Buck Woody. Thanks Buck for sharing info on such small but important things.

Enjoy!

April 23, 2008

Arithmetic overflow error converting varchar to numeric

Filed under: Tips & Tricks — msrviking @ 10:33 AM

Sometime last week, I received an email from one of the developers saying that she was unable convert a varchar value of ‘3.43E-07′ to numeric.

I promised that I would help her, and here is what I could do and well she was delighted with the solution. Here is the example, I had given

DECLARE
@T  TABLE (VAL1 VARCHAR(50))
INSERT INTO @T VALUES (‘3.43E-07′)
SELECT * FROM @T
SELECT CONVERT(NUMERIC(38,10),CONVERT(FLOAT,VAL1)) FROM @T

I have been having tough time with the datatype FLOAT in several projects, and I owe you all a separate blog entry on this where in I shall cover the problems and solutions.

Thanks!

Blog at WordPress.com.