I am having some difficulty writing a relatively basic query. The objective is to retrieve the new stories (headlines) for the past 3 days from the database. Since each headline can be assigned multiple categories (topics) the query returns a row for every headline assignment. I can't use the 'Group By' expression because one of the columns is nText.
So basically if there is an article written yesterday, "I Love Cats" that gets assigned both topics 'CATS' and 'PETS' I only it returned with the first topic assigned... 'CATS'. Here is a little image of the three tables being called:
http://64.225.154.232/temp_dbDiagram.gif
I don't think that this query is too difficult, but I'm just getting my feet wet with writing queries that are more than select * from whatever. Any insight or recommendations are greatly appreciated.
SELECT headline.HEADLINE_ID, headline.HEADLINE_TITLE, headline.HEADLINE_DATE, headline.HEADLINE_THUMBNAIL,
topic.TOPIC_NAME, topic.TOPIC_URL
FROM tbl_CCF_Headlines headline INNER JOIN
tbl_CCF_Headlines_Topics ON headline.HEADLINE_ID = tbl_CCF_Headlines_Topics.HEADLINE_ID INNER JOIN
tbl_CCF_Topics topic ON tbl_CCF_Headlines_Topics.TOPIC_ID = topic.TOPIC_ID
WHERE (headline.HEADLINE_DATE IN
(SELECT TOP 3 HEADLINE_DATE
FROM tbl_CCF_HEADLINES
GROUP BY HEADLINE_DATE
ORDER BY HEADLINE_DATE DESC))
ORDER BY headline.HEADLINE_DATE DESCTry to cast youe text column to varchar(1000).|||What if the nText-field contains more than 1000 characters? What if it contains more than 4000 characters which I believe is the limit for nVarChar? I have this very same situation and am yet to find a solution...
-Tuukka
Showing posts with label retrieve. Show all posts
Showing posts with label retrieve. Show all posts
Tuesday, March 27, 2012
Thursday, February 16, 2012
Backup Wizard 2005 Standard
I have a new installation of SQL 2005 standard and I cannot create an
automatic backup. When I launch the wizard I get an error " Failed to
retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
then create my backup job, but upon completion I get these 2 error:
Invalid column name 'from_msx'.
Invalid column name 'has_target'.
I have to manually launch the backups each night and that work fine. I
previously was using Sql 2000 and the backup jobs ran without any problems.On Apr 19, 1:40 pm, Todd <T...@.discussions.microsoft.com> wrote:
> I have a new installation of SQL 2005 standard and I cannot create an
> automatic backup. When I launch the wizard I get an error " Failed to
> retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
> name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
> then create my backup job, but upon completion I get these 2 error:
> Invalid column name 'from_msx'.
> Invalid column name 'has_target'.
> I have to manually launch the backups each night and that work fine. I
> previously was using Sql 2000 and the backup jobs ran without any problems.
Is this a server you upgraded to 2005 was a target server and prior to
upgrade did the server have master server?|||No this is a new Server not an upgrade. I moved the 2000 db over to this
server.
"Bulent" wrote:
> On Apr 19, 1:40 pm, Todd <T...@.discussions.microsoft.com> wrote:
> > I have a new installation of SQL 2005 standard and I cannot create an
> > automatic backup. When I launch the wizard I get an error " Failed to
> > retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
> > name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
> > then create my backup job, but upon completion I get these 2 error:
> > Invalid column name 'from_msx'.
> > Invalid column name 'has_target'.
> >
> > I have to manually launch the backups each night and that work fine. I
> > previously was using Sql 2000 and the backup jobs ran without any problems.
> Is this a server you upgraded to 2005 was a target server and prior to
> upgrade did the server have master server?
>
automatic backup. When I launch the wizard I get an error " Failed to
retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
then create my backup job, but upon completion I get these 2 error:
Invalid column name 'from_msx'.
Invalid column name 'has_target'.
I have to manually launch the backups each night and that work fine. I
previously was using Sql 2000 and the backup jobs ran without any problems.On Apr 19, 1:40 pm, Todd <T...@.discussions.microsoft.com> wrote:
> I have a new installation of SQL 2005 standard and I cannot create an
> automatic backup. When I launch the wizard I get an error " Failed to
> retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
> name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
> then create my backup job, but upon completion I get these 2 error:
> Invalid column name 'from_msx'.
> Invalid column name 'has_target'.
> I have to manually launch the backups each night and that work fine. I
> previously was using Sql 2000 and the backup jobs ran without any problems.
Is this a server you upgraded to 2005 was a target server and prior to
upgrade did the server have master server?|||No this is a new Server not an upgrade. I moved the 2000 db over to this
server.
"Bulent" wrote:
> On Apr 19, 1:40 pm, Todd <T...@.discussions.microsoft.com> wrote:
> > I have a new installation of SQL 2005 standard and I cannot create an
> > automatic backup. When I launch the wizard I get an error " Failed to
> > retrieve data for this request. (Microsoft.Sqlserver.SmoEnum) Invalid column
> > name 'msx_job_id'. (Microsoft SQL Server, Error: 207). I click okay and I can
> > then create my backup job, but upon completion I get these 2 error:
> > Invalid column name 'from_msx'.
> > Invalid column name 'has_target'.
> >
> > I have to manually launch the backups each night and that work fine. I
> > previously was using Sql 2000 and the backup jobs ran without any problems.
> Is this a server you upgraded to 2005 was a target server and prior to
> upgrade did the server have master server?
>
Subscribe to:
Posts (Atom)