Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mounikakala
Starting Member
14 Posts |
Posted - 2008-08-26 : 13:05:30
|
| Hi,I have the following situation.Each Day I run a report for the Distinct list of records which meet my filtering criteria, and then update a table with those records along with that distinct recordsthe Following example would explainMy table Structure would be with 2 columns as Name Varchar(30) and Date DatetimeI am writing a report for the people who met a certain criteria and found 10 records for the day.Now I can insert the Name Values into the table with my structure but I have problem inserting the toDay's Value into the Table in a single statement.how do I insert the Values in a single statementThanksMounika |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 13:22:34
|
quote: Originally posted by mounikakala Hi,I have the following situation.Each Day I run a report for the Distinct list of records which meet my filtering criteria, and then update a table with those records along with that distinct recordsthe Following example would explainMy table Structure would be with 2 columns as Name Varchar(30) and Date DatetimeI am writing a report for the people who met a certain criteria and found 10 records for the day.Now I can insert the Name Values into the table with my structure but I have problem inserting the toDay's Value into the Table in a single statement.how do I insert the Values in a single statementThanksMounika
did you meant current days date? then uise getdate()INSERT INTO YourTableSELECT Name,GETDATE()FROM table |
 |
|
|
mounikakala
Starting Member
14 Posts |
Posted - 2008-08-26 : 15:13:56
|
| Hi Look at the Example.My Transaction Table has Millions of records. Out of which there can be 200,000 Records per day. So I cannot give the Sample data based on that. Now my requirement is that on any Given Day, I can query for the distinct Names that macth my search criteria. But the Query results a list of Names.Table Structure is like This.Name Date----------------------I am able to Query the records and Insert into the table in a single shot and the table looks like this. And then I am updating the Table with the getdate() Value where ever the Date is Null.Name Date----------------------A B C D E F G H but I need to Insert into the table both the Name and Date Value at the same time and the date value will be Same All the records with the Date value on which day I run the query.Name Date----------------------A Aug 26 2008B Aug 26 2008C Aug 26 2008D Aug 26 2008E Aug 26 2008F Aug 26 2008G Aug 26 2008H Aug 26 2008I hope this is clear.ThanksMounika |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 23:51:28
|
| What you can given here can be achieved by using query that i've given. did you try it? |
 |
|
|
|
|
|