views:

29

answers:

2

Hello guys, i have some experience with MySQL but none with SQL Server, i have a computer who host a database (SQL Server 2000) and i have local access to it. The think is that one column of the table NomAntiguedad need to be change from a given date period; I need to multiply by 0.01 all the values of the column between the values of mesano (05/2007 to actual date, format: MM/YYYY).

How can i have VISUAL access to the data base, like when i administrate my data bases on PhpMyAdmin in order to see the tables format?

What would be the syntax of the command to do what i need?

+3  A: 

How can i have VISUAL access to the data base, like when i administrate my data bases on PhpMyAdmin in order to see the tables format?

There's the defacto SQL Server Management Studio (Express Edition is free), or Toad for SQL Server (free if <5 people use it in-house) applications...

The think is that one column of the table NomAntiguedad need to be change from a given date period; I need to multipli for 0.01 all the values of the column between the values of mesano (05/2007 to actual date, format: MM/YYYY).

You need to use an UPDATE statement:

UPDATE NomAntiguedad
   SET your_column = .01 * your_column
 WHERE mesano = '05/2007'

Mind that you might have to use CAST/CONVERT to explicitly handle the data type returned from the ".01 * your_column" calculation because you could be loosing precision depending on the column's data type.

OMG Ponies
+3  A: 
UPDATE NomAntiguedad
SET <Column You're Updating> = .01*<Column You're Updating>
WHERE REPLACE(mesano, '/', '/01/') BETWEEN '5/1/2007' AND getDate()

I'm assuming you're date format is accurate and never changes.

Ian Jacobs
"BETWEEN '5/1/2007' AND getDate()" that is not the date format the database use. Is MM/YYYY. Knowing that how can i change the syntax of your command? Thanks
DomingoSL
Is mesano stored as a DateTime column in your database? If so SQL server should just know how to handle it.
Ian Jacobs
@Ian Jacobs: MM/YYYY isn't a standard date format; to support the slash, it'd have to be text based (VARCHAR, etc.)
OMG Ponies
Ok I stand corrected :-) See my update above. It feels a bit hack-ish, but I always prefer treating Dates as Dates instead of varchar strings.
Ian Jacobs