Monday, September 9, 2013

[SQL Server] comparing a column to Todays date

[SQL Server] comparing a column to Todays date


comparing a column to Todays date

Posted: 09 Sep 2013 04:01 AM PDT

how do we compare a column name "LogDATE" to todays date and if its exists we print out a statement saying the record exists. Ideally we would check the max row and check that the max row has todays date and if it does we print out a statement as " record exist no further action"thanks I tried this but it will give me 9/9 and 9/8 i just want 9/9 or just todays date SELECT LogDATEfrom Xlog WHERE LogDATE >= Convert(datetime, Convert(int, GetDate()))

Pivot views

Posted: 08 Sep 2013 11:52 PM PDT

I am currently reading Itzik Ben Gans book about Microsoft Server 2008 TSQL Fundamentals and I have run into another code example I cannot seem to grasp. The following code runs correctly and selects the data how it should:[code] Select empid, SUM(Case when custid = 'a' then qty end) As A, SUM(Case when custid = 'b' then qty end) AS B, SUM(Case when custid = 'c' THEN qty end) AS C, SUM(Case when custid = 'd' THEN qty end) AS DFROM dbo.ordersGROUP BY empid;[/code]I just don't seem to understand how/why this works? Thank you!

Does stored procedure exist?

Posted: 08 Sep 2013 10:17 PM PDT

Hi all!I want to check about a sored procedure does exist before i Create/alter it.How to?When it's about a table, SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '[TABLE_NAME]' just does the trick - there must be something very similar.Best regardsEdvard Korsbæk

No comments:

Post a Comment

Search This Blog