Friday, March 23, 2012
Movenext to next record in dataset if condition not met!
dataset if a condition is not met? I can get it to put a blank when the
condition is true, but the report is displaying the row where the data would
be. So, it looks like a blank line.
For example I am trying to say If the field value coming in is < 6 display
value Else skip to next record.
Can anyone help?dillig wrote:
> Can anyone help?
You have to set a filter for the whole table-row.
That should help
frank
--
www.xax.de
Monday, March 12, 2012
move record from TableA to TableB at a specified time of the record
record?
Thanks for any hints.
TonyTony WONG wrote:
> How can i move record from TableA to TableB at a specified time of the
> record?
> Thanks for any hints.
> Tony
One obvious way might be like this:
CREATE VIEW TableB
AS
SELECT col1, col2, col3
FROM TableA
WHERE datetime_col <= CURRENT_TIMESTAMP
GO
If you want to archive data on a regular bases with INSERT statements
then create a proc and schedule it as a job.
In SQL Server 2005 you may want to consider using a partitioned table
instead.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Thanks for your prompt advice
may i know the best way to trigger this sql?
add a job to execute in every 5 minutes?
thanks a lot.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org>
'?:1147069404.714636.117510@.y43g2000cwc.googlegroups.com...
> Tony WONG wrote:
> One obvious way might be like this:
> CREATE VIEW TableB
> AS
> SELECT col1, col2, col3
> FROM TableA
> WHERE datetime_col <= CURRENT_TIMESTAMP
> GO
> If you want to archive data on a regular bases with INSERT statements
> then create a proc and schedule it as a job.
> In SQL Server 2005 you may want to consider using a partitioned table
> instead.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||Tony WONG wrote:
> Thanks for your prompt advice
> may i know the best way to trigger this sql?
> add a job to execute in every 5 minutes?
>
For what purpose would you want to do this every 5 minutes? That seems
much too frequent for a simple archiving process. I'd say there ought
to be a better solution - maybe replication, mirroring or triggers for
example - but that depends on just why you want two tables to replicate
the same data.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Tony WONG wrote:
> Thanks for your prompt advice
> may i know the best way to trigger this sql?
> add a job to execute in every 5 minutes?
>
For what purpose would you want to do this every 5 minutes? That seems
much too frequent for a simple archiving process. I'd say there ought
to be a better solution - maybe replication, mirroring or triggers for
example - but that depends on just why you want two tables to replicate
the same data.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||in fact it is a SMS system
TableA store the record to be sent to TableB(production table)
Once records add to TableB, the record will be distributed to SMS queue.
The question is what is the best method to do it (add a job to do every 5
minutes) in terms of hardware resource (cpu loading...)
by the way, how to add a job in every 5 minutes?
Thanks a lot for your assistance.
tony
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org>
'?:1147109579.095918.27650@.g10g2000cwb.googlegroups.com...
> Tony WONG wrote:
> For what purpose would you want to do this every 5 minutes? That seems
> much too frequent for a simple archiving process. I'd say there ought
> to be a better solution - maybe replication, mirroring or triggers for
> example - but that depends on just why you want two tables to replicate
> the same data.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||Tony WONG wrote:
> in fact it is a SMS system
> TableA store the record to be sent to TableB(production table)
> Once records add to TableB, the record will be distributed to SMS queue.
> The question is what is the best method to do it (add a job to do every 5
> minutes) in terms of hardware resource (cpu loading...)
> by the way, how to add a job in every 5 minutes?
Doesn't make much sense to me as you've described it. If the date is
what determines when a row is to be processed then why do you need two
tables? You could have just one table and create a view as I first
suggested.
Two similar tables in the same database is usually considered to be a
logical design flaw. It is also inefficient if it forces you to insert
the same data twice, especially if you have to do so every 5 minutes.
Consider changing the design.
If you have to work with what you have then you could either implement
a trigger or create a job (lookup sp_add_job in Books Online). If the
inserts are always to be time driven then use a job.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Friday, March 9, 2012
Move first record from a flat file to another
Hi,
i have simple requirement...but dont know how to proceed. I need to move the first record from a flat file (file1) to another flat file(file2) using SSIS, file1 will have many records but i just need the first one alone to be moved. Any pointers on this would be of much help.
Thanks,
raj
A batch file might be a better fit for this easy task:
Syntax:
getFirstLine.bat sourcefile > destinationfile
getFirstLine.bat
@.echo off
if %1'==' echo which file? && goto :eof
:main
set First=Y
for /f "tokens=*" %%L in (%1) do call :Getfirst %%L
goto :eof
:Getfirst
if %First%'==Y' echo %*
set First=N
goto :eof
:eof
|||Thanks Phil for your prompt reply, I managed to do the same using script component.
Thanks again
Raj
Saturday, February 25, 2012
move database record
i have no problem to select all records from the table, but how to copy or move these selected records to other table which contain same field as the orriginal.
thanksINSERT INTO table2 (col1, col2, col3...)
SELECT col1,col2, col3
FROM table1
WHERE ...|||ndinakar, can u guide me more details. example i have one table call student, inside got id and name and move this record to a table call student2. can u guide me complete sql statement, because i new to the sql, i bit confuse in line 1 and line 2. thanks
INSERT INTO table2 (col1, col2, col3...)
SELECT col1,col2, col3
FROM table1
WHERE ...|||
INSERT INTO student2 (id,name)
SELECT id,name
FROM student
WHERE {something}
{something} could be ID=some number or name='some name' etc
|||is't this method is for one reord only? how about if i want to move 1000 records from table student to table student2 ?. thanks|||You move as many records as your SELECT statement returns.