Showing posts with label displayed. Show all posts
Showing posts with label displayed. Show all posts

Monday, March 12, 2012

Help needed- regarding datediff functio

Hi,
I have to compare every row in month column in xyz table with current month. If there is mismatch, then error message must be displayed.
I have used DATEDIFF (MM, Select getdate(), select month from xyz ), but I am getting error at MM. Can anybody fix this issue.

The syntax you have is incorrect. Try something like this:

SELECT [Month], Mismatch=CaseWHENMonth(Getdate())= [Month]then 0ELSE 1END

FROM MyTable

|||

This will work:

1SELECT MonthColumn,2 IsMatchColumn =3CaseWHENDatePart(Month,GetDate()) = MonthColumn4Then 0-- Yes (Matched)5Else 1-- No (Not Matched)6END78FROM YourTableName9

Good luck.

Friday, March 9, 2012

help needed ...to update the datatable

hi,

I have my database stored in the sqlserver 2005. Using the table name i am retrieving the table and it is displayed to the user in the form of datagridview.I am allowing the user to modify the contents of the table, including the headers. Is it possible for me to update the table straightway rather than giving a sql update command for each and every row of the table .

Pls reply asap....

-Sweety

Sure is.

Though this really isnt a SQL Issue you have. You also forgot to mention what programming language you are using (VB.NET, C# etc) If you are using the datagrid and a dataset, then its easily possible however, depending on what .net platform you are using (1.1, 2.0) if you tell us, we will be able to help further.|||

hi,

sorry for the duplicate posting.I am using VC# and .net 2.0..

bye

Sweety