| LearnSQLWithBru -- SQL Server Forums |
|
September 09, 2010, 10:24:00 am
|
|||
|
|||
| News: |
| Home | Help | Search | Login | Register |
|
1
on: Today at 08:53:22 am
|
||
| Started by saqlainkhan - Last post by Bru Medishetty | ||
|
Thanks Saqlain... Appreciate your time and effort..
|
||
|
2
on: Today at 08:02:21 am
|
||
| Started by saqlainkhan - Last post by saqlainkhan | ||
|
Hi,
Last week i came across where the first day and last day of a month needs to be calculated based on a given date(or datetime). Here is how to get that. I have used a ScalarFunction This will return the firstofthemonth Code: CREATE FUNCTION [UdfGetFirstDateofMonth] (@Date as DateTime) RETURNS date AS BEGIN Declare @FirstDate DateTime Set @FirstDate = DateAdd(Day, 1, @Date - Day(@Date) + 1) -1 RETURN @FirstDate END GO and this will return the last day of the month Code: CREATE FUNCTION [UdfGetLastDateofMonth] (@Date as DateTime) RETURNS date AS BEGIN Declare @LastDate DateTime Set @LastDate = DateAdd(Month, 1, @Date - Day(@Date) + 1) -1 RETURN @LastDate END GO result set: select dbo.udfGetFirstDateofMonth ('2010-09-09') 2010-09-01 select dbo.udfGetLastDateofMonth ('2012-02-27') 2012-02-29 |
||
|
3
on: September 02, 2010, 01:56:20 pm
|
||
| Started by rohit - Last post by saqlainkhan | ||
|
You can query the SQL Server maintains Metadata using System Views, Catalog Views and Compatibility Views. like Bru mentioned earlier... Also if you do a quick help search on your local ss you will be provided with detailed explaination about Here are a few more links which would hopefully answer your question. http://social.msdn.microsoft.com/forums/en-US/sqldatabaseengine/thread/4e3d2361-1156-43b0-88c7-0c19d863b513 http://www.databasejournal.com/features/mssql/article.php/1460131/SQL-Servers-Metadata-Views.htm http://codebetter.com/blogs/raymond.lewallen/archive/2005/03/04/56519.aspx |
||
|
4
on: September 02, 2010, 06:21:16 am
|
||
| Started by rohit - Last post by rohit | ||
|
What is a data dictionary? how is data stored in it and why is it so important for a database. Please suggest any links.
|
||
|
5
on: August 31, 2010, 08:01:31 am
|
||
| Started by saqlainkhan - Last post by Bru Medishetty | ||
|
Frankly speaking, I am not aware of how to do it, as it has been like this way always (a backup of a higher version would not work in the lower version)..
The only work around which I am aware of is to script the database and objects as described in this blog of mine.. http://learnsqlwithbru.com/2010/03/07/scripting-database-objects-in-sql-server-2008/ Post any questions if you have... |
||
|
6
on: August 31, 2010, 07:33:00 am
|
||
| Started by saqlainkhan - Last post by saqlainkhan | ||
|
I have a SQL Server 2008 R2 instance that needs to be backedup and restored on SQL Serever 2008.
In doing so i get the following error mesage: The database was backed up on a server running version 10.50.1600. That version is incompatible with this server, which is running version 10.00.2531. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.Smo) How can i backup the SQL 2008 R2 database to be compatible with SQL 2008? |
||
|
7
on: August 31, 2010, 06:47:29 am
|
||
| Started by saqlainkhan - Last post by saqlainkhan | ||
|
Thanks...
I had a feeling seeks are always better than scans but wanted to clarify that. Will wait for the blog to get posted! Thanks! |
||
|
8
on: August 31, 2010, 06:44:46 am
|
||
| Started by saqlainkhan - Last post by Bru Medishetty | ||
|
In short, Index Seek is better than an Index Scan.
I would be replying here or may be a blog on this topic and post the blog link here... |
||
|
9
on: August 31, 2010, 06:43:32 am
|
||
| Started by saqlainkhan - Last post by saqlainkhan | ||
|
thanks!
![]() |
||
|
10
on: August 31, 2010, 06:38:42 am
|
||
| Started by saqlainkhan - Last post by Bru Medishetty | ||
|
I would suggest approaching this in this way.
Break down the complex code into blocks/ chunks of smaller SQL Statements that is easier to understand. Test the code against a data set that is custom built by you, example the actual table data can all be truncated and replaced with couple of records which are manually entered, this way you should be having a better idea based on the data (since the data is fed by you maunally).. Then if there is still something that is beyond your comprehesion, if the developer (who wrote the scripts) is available, try asking their help in understanding. If this is not possible, then you need to try posting the scripts, with some test data (tables, sprocs, views etc etc) in online forums and seek help.... |
||