|
Hi,
I have an archives sectionon my website. It must display all news except the news of the current. So if we work on the current year and month, then all news articles mut display except news articles that were added for February 2005. My logic says that they SQL statement must look somthing like:
SELECT NewsID_PK, NewsSubject, NewsDateAdded
FROM tblNews
WHERE (YEAR(NewsDateAdded) <> 2005 AND MONTH(NewsDateAdded) <> 2)
ORDER BY NewsDateAdded DESC;
But this doesn't display correctly. If I replace the AND with anOR thenit works,like this:
SELECT NewsID_PK, NewsSubject, NewsDateAdded
FROM tblNews
WHERE (YEAR(NewsDateAdded) <> 2005 OR MONTH(NewsDateAdded) <> 2)
ORDER BY NewsDateAdded DESC;
I don't understand why. Can some one please explain why. If there is a better way of writing this statement, please let me know.
Any help and suggestions would be appreciated!!
Thanks
Brendan
|
|
|
|
|
|
The first one seems to be correct. The second one isn't because will eliminate all dates containing 2005 as year and 02 as month
|
|
|
|
|
Hi,
I have the following 2 questions with which I need help with...
QUESTION 1:
I want to add a news article to a SQL Server 2000 database using classic ASP. I need to know what characters I should search for in the text which may/can display incorrectly.
For example this is what I do when there is an apostrophe in the text:
Replace(Request.Form("txtBody"), "'", "''")
For what other characters must I be aware of when adding to the database table?
QUESTION 2:
When displaying database text to a reader (through a web page) that has line breaks in it,is this the best way to do it? arr(2, 0) is a field in my table called NewsBody.
Replace(arr(2, 0), Chr(10), Chr(10) & " ")
With regards to question 1, what else needs to be taken care of when displaying data from a database table.
Any help and suggestions would be appreciated!!
Thanks
Brendan
|
|
|
|
|
|
I want to create a new table in SQL Server, which will populate Date, weeks, months and years. I want the dates starting from 1st January 2004 and finishing on 31st December, 2008. Basically i want to use this table as a mapping, so i know if dates are in between this range this is week 1, if dates are in between this range this is week 2, somthing like this.
I know this is possible in a sql query by writing case statement. But this is a lot of coding.
I was just wondering if someone could tell me how could i create a table like this by using DTS (ActiveX VBScript). Some kind of loop....
The problem is i do not know how to create a new table from ActiveX and insert data into it from ActiveX. Just letting you know that you can create/truncate table by using "Excute SQL Task". But it does not let you to create a workflow in between ActiveX and "Excute SQL Task". I think i got to create the connection in the ActiveX but not sure.
Can someone help, please? I am looking for a table like this :
Date_Time Week_No Month Year
3/1/2005, 09:01:44 PM 1 Jan 2005
4/1/2005, 09:01:44 PM 1 Jan 2005
.....
10/1/2005, 09:01:44 PM 2 Jan 2005
11/1/2005, 09:01:44 PM 2 Jan 2005
...
Thanks
Bob
|
|
|
|
|
HI
How i can create a rownumber column in my view results?
like this sample:
select f1 from table1
go
results:
f1
---
www
aaa
vvv
bbb
I WANT THIS FORM:
rowno f1
---- ---
1 www
2 aaa
3 vvv
4 bbb
thanks
|
|
|
|
|
Hi there. It depends on the database you are using - which one?
|
|
|
|
|
|
Okay. Unfortunately, there isn't a simple way (like Oracle's ROWNUM) to do this in SQL Server 2000. SQL Server 2005 will support a function for this, but in 2000 you have basically two directions you can go. One is to use a temporary table with an identity column - probably in a stored procedure so you can reuse it like you would a view. http://www.sqlteam.com/item.asp?ItemID=1491[^]
Another would be to use a specially constructed auto-join query designed to rank the results.
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q186133[^]
I suppose you could also create a stored procedure that loops through a cursor, but the performance would probably be bad.
|
|
|
|
|
You could create a temp table with an autonumber field for the "rowno" and do a INSERT SELECT from your current resultset.
Else, have a look at this [^]which might be of help.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "Most of us are programmers, but a few use VB", Christian Graus
|
|
|
|
|
hi
i saw that page thank u
BUT
i want to use it in views.
i cant create an extra table
tanks again
|
|
|
|
|
Hi all
I have been reading through the SQL Server 2000 database book, and I know that there are 3 types of back-up database: full backup, differential backup and transaction log backup. So which one is the best recommendation?
I'd appreciate for anyone whoi can help me out!
Cheers,
Kelly
|
|
|
|
|
Kelly Giang wrote:
full backup, differential backup and transaction log backup. So which one is the best recommendation?
It depends on what you want to achieve...
A full backup creates a backup of the whole database
A differential backup creates a backup of just the differences between the last backup and now
A transaction log backup creates a backup of just the transaction log since the last backup.
Restoring a full backup means you can recover to the point of the backup. Restoring a differential backup ontop of that means you can recover to the point of the last differential backup, and a transaction log backup can be used to allow you to restore to an exact point in time or to the point of failure.
You should read the SQL Server 2000 Books-online[^] for more information.
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
Thanks a lot Colin!
Cheers,
Kelly
|
|
|
|
|
Can someone help me with this SQL statement? I'm wanting a bigint with a datetime stamp similar to:20050211102341780
Here's my SQL statement:
<br />
INSERT INTO TSK2 EXECUTE ('SELECT' ' DATEPART([YEAR], CURRENT_TIMESTAMP), DATEPART([MONTH], CURRENT_TIMESTAMP), DATEPART([DAY], CURRENT_TIMESTAMP), <br />
DATEPART([HOUR], CURRENT_TIMESTAMP), DATEPART([MINUTE], CURRENT_TIMESTAMP), DATEPART([SECOND], CURRENT_TIMESTAMP) <br />
DATEPART(MILLISECOND, CURRENT_TIMESTAMP)'' AS TSK2_DATE_TIME, 0 AS TSK2_PRIORITY, 341 AS TSK2_ACTION')<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I won't claim that it is efficient but if you only use it when inserting records it shouldn't effect performance that heavily.
SELECT
CAST(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
CONVERT(VARCHAR(30),CURRENT_TIMESTAMP,21)
,'-','')
,':','')
,'.','')
,' ','')
AS BIGINT)
|
|
|
|
|
Awesome....works great!
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Is it possible to append a selected column onto the end of a selected row? For instance, I have 2 selects. The first only returns 1 row. The second returns many rows, but only in 1 column. Can I easily append all of the rows from the 2nd select onto the end of the row in the first select, without using a cursor? Even better, we'd like to concatenate all of the rows from the 2nd select into one long string, and just append that string onto the end of the 1 selects row. What might be the best approach to this?
Thanks!
|
|
|
|
|
Assuming you are using SQL Server
Here is a little sample of creating a comma delimited list from a set of rows. You can run it in SQL Query Analyzer by replacing [Name]/[Weather] with field/table of your choice. Careful that you don't pick a query that goes beyond the 8000 character limit.
This doesn't get rid of the cursor when assembling the final table since you will have to reset @sample to null at each row iteration. It does get rid of the nasty 'rows to 1 column' issue though.
DECLARE @sample VARCHAR(8000)
SELECT @sample = ISNULL(@sample + ', ','') + [Name]
FROM [Weather]
PRINT @sample
|
|
|
|
|
I have Table in ACCEss. i want it to be exported or moved to oracle. I had tried by making ODBC connection string and exporting the table.
It shows table in tablespace (i.e Whem we fire
Select * from tab; )
But when we fire desc or any select query on table
it shows object does not exists/....
In short i want to export mine table from access to oracle
I m having many table's that r to be moved to oracle with data. Suggest Possible way: confused:
|
|
|
|
|
hi people,
I have a question concerning the text/ntext data types. I have read that the maximum number of characters that we can place in an SQL row is 8060. It sounds quite strange since the text data type can hold more than 2 million. Now when I declare a field as "text", I notice that the size is 16, which is probably 16 bytes. This probably means that in fact, the field, is just like the interger field. Is it correct to say so? Is the "text" field in fact a pointer to a location where the 2 million-character (or more) data is located?
I have tried to insert manually (using the SQL Enterprise Manager) a 3000-character text into a field of "text" data type, but it doesn't permit so.
My question is, how can I insert text in a "text" data type field?
thanks,
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
The largest you can set a char or varchar column to is 8000 bytes. An nchar or nvarchar column can be up to 4000 characters. The size of the whole row, including overhead, must be less than 8060 bytes.
The TEXT data type can actually hold up to 2GB of data. NTEXT is limited to 2^30 - 1 characters (again, 2GB of data). In the typical case, the row holds a 16-byte pointer to the location of the actual data. An additional index is created on the table to indicate where the text/image data is located.
To insert text data manually, use the SQL WRITETEXT or UPDATETEXT commands in Query Analyzer.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for the reply, I checked those functions and the help that comes with the Query Analyzer. I managed to insert data but when I tried to retrieve the field, still using the QA, I only got a portion of it, eventhough I had the size to 0 in the READTEXT function, which should normally return a chunk of 4KB (as the help says).
I'm thinking this might be just because of QA, because when I put a size that is bigger than the real size of the text, I get an error that says that the size is greater than the actual size, and it gives me the correct number of characters, which in my case is 2800.
So I suppose that the result given by the QA is just a fixed number of characters, regardless of the real size of the text?
To use this programmatically, how would I proceed? Would I use a function or a stored procedure? or is there a special way?
thanks a lot for your help.
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Did anybody knows how to move Olap cubes from one computer to another. So far I have to do it manually on the other computer. Thanks
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|