Teen Programmers Unite  
 

 

Return to forum top

sql 7

Posted by jrl [send private reply] at June 12, 2002, 02:45:15 PM

what is the syntax or is there a syntax in sql 7 to replace lets say 7 date fields in a table with one command. ie: name a variable, dt = 2002-06-12 then set each date field = dt ??? that way if i need to change the dates again i just need to change dt instead of every set command.

Posted by unknown_lamer [send private reply] at June 12, 2002, 07:42:34 PM

There is no SQL version 7! Do you mean MS SQL 7...

Posted by jrl [send private reply] at June 13, 2002, 04:35:24 PM

yes that is what i mean, didn't know other companies wrote sql.

Posted by AngelOD [send private reply] at June 13, 2002, 06:19:01 PM

SQL is a language, not a product.. It's actually "MS SQL Server 7"

Posted by gian [send private reply] at June 13, 2002, 08:14:46 PM

There are many SQL servers, most of them superior to Microsoft SQL server.
Take a look at mySQL (http://www.mysql.org) and Interbase (http://www.inprise.com).

Posted by unknown_lamer [send private reply] at June 13, 2002, 10:30:46 PM

Don't forget postgres! It is really fast when you turn off the fsync() after every database operation (most people don't know you can turn that off, hence people think it is slow). I think one benchmarked showed postgres being faster than oracle 8i or something.

Posted by jrl [send private reply] at June 14, 2002, 11:39:03 AM

Ok......but what about my question?

Posted by Psion [send private reply] at June 14, 2002, 04:31:19 PM

I've never heard of linked fields like that in SQL.

Posted by jrl [send private reply] at June 17, 2002, 03:44:08 PM

Finally....I have the answer to my original question. If anyone is interested, let me know and I will be more than happy to give you the answer. Thanks DATAPOINT

Posted by unknown_lamer [send private reply] at June 17, 2002, 04:52:46 PM

/me knew the answer to the question last night when he was reading the postgresql manual

Something about using UPDATE...

UPDATE table SET field = new_value, ... WHERE (some expression); or something like that.

Posted by Psion [send private reply] at June 17, 2002, 08:00:15 PM

Oh, then I misread the question. It looked like he wanted to set a number of fields to use a shared/linked variable, so that when he changed that variable, everything linked to it would automatically change.

Posted by unknown_lamer [send private reply] at June 17, 2002, 09:26:19 PM

oops, I guess I misread the question.../me hits self with lamer stick.

Anyway, I'd like to see the answer...

Posted by jrl [send private reply] at June 18, 2002, 02:30:02 PM

here's the syntax:

declare @date smalldatetime
set @date = '2002-06-18'
update 'a table name'
set 'thisdate' = @date
set 'thatdate' = @date
set 'otherdate' = @date

so all date fields = to @date are changed to june 18. usually a good idea to begin the command with 'begin tran' then if it's ok run 'commit' or if not 'rollback'

or if you have a alpha field then the syntax is:

declare @field varchar(field size)

enjoy...........

Posted by unknown_lamer [send private reply] at June 18, 2002, 07:09:13 PM

clinton@vsynth:guile-core$ createdb test
CREATE DATABASE
clinton@vsynth:guile-core$ psql test
Welcome to psql, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

test=> declare @date smalldatetime;
ERROR: parser: parse error at or near "@"
test=> \q

So I guess it is MS SQL specific...

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.