Posted in MSSQL, tagged SQL on March 5, 2008 | Leave a Comment »
I m found a way to get the first day of the year without hardcode in the stored procedure.
here the SQL script.
convert
(char(20), convert(char(4), year(getdate())) + ‘/01/01′, 111)
To test it, simply put “select” in front of the pink color script above.
The result, if your system current year is 2008, it will return 2008/1/1!
Read Full Post »
Posted in MSSQL, tagged SQL on February 18, 2008 | Leave a Comment »
to get a total value from both query, the only way to do is UNION both query and a Select Statement on top of UNION.
SELECT Sum(Col1) as A, Sum(Col2) as B
FROM ( SELECT Col1, Col2 FROM TableA
UNION Select Col1, Col2 From TableB ) A
Read Full Post »
Posted in MSSQL, tagged SQL on January 30, 2008 | Leave a Comment »
I have a column called FileName with values such as “100.wmv, 200.wmv, 999.wmv”, but i just want to display “100, 200, and 999″ without wmv extension.
so I just use substring to solve the problem
select substring(FileName, 1, 3) as FileName from [TableA]
Here the explaination to use : SUBSTRING(string to manipulate, start index, length of string to [...]
Read Full Post »