.NET Programming With Me

SQL Server: Like Operator in DateTime

Actually i've not used the like operator for searching since it tales timepart also. The easy way to search for a record using datepart from the datetime field is as:

SELECT * 
FROM   my_sales 
WHERE  DATEPART(yy, date) = 2013
AND    DATEPART(mm, date) = 08
AND    DATEPART(dd, date) = 29)

find this way easy to read, as it ignores the time component, and you don't have to use the next day's date to restrict your selection.

SQL Server: Generating the Schema and Data with SqlServer 2008 R2 Management Studio

1. Right click on the database.
2. Select Tasks -> Generate Scripts.
3. Select the "Script entire database and all database objects" radiobutton.
4. Click Next.
5. In the "Scripting Options" screen, click the "Advanced" button.
6. In the "General" category change the "Types of data to script" value to "Schema and Data".
7. Click OK.
8. Click Next.

Now, you will get the schema scripts as well as the tabulated data of the database.