table data script file with date range

kasim mohamed 581 Reputation points
2021-06-02T07:23:49.443+00:00

Hi,

I need specific table data script file '.sql' file only specific date range (like insert into)
when i get it through database -> task -> generate script it give all table entries. but i need only specific date range.

note: i dont have admin rights

Thanks

Developer technologies Transact-SQL
SQL Server Other
{count} votes

Accepted answer
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-06-08T08:34:56.273+00:00

    Hi @kasim mohamed ,

    If so, why did you not try the suggestion that I mentioned above. Select the data only specific date range , then insert the data into a new table, then you can get a table with the data that specific date range.

    If my suggestion did not meet your requirement, please feel free to let me know.


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2021-06-02T07:36:55.927+00:00

    but i need only specific date range.

    There is no option in the script wizard to filter the data on certain condition; it always scipts all data.
    You have to head out for other tools.

    0 comments No comments

  2. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-06-03T08:23:45.637+00:00

    Hi @kasim mohamed ,

    > when i get it through database -> task -> generate script it give all table entries. but i need only specific date range.

    No, Generate script wizard could meet your requirement. It will script all data. It can choose the database object, but could do a condition filter as Olaf mentioned.

    If you only want to get data between two dates from one table, you can try to using below T-SQL.

    Select  * into table2 from dbo.Table1 where date BETWEEN '6/1/2021' AND '6/10/2021'  
    

    Below is a test in my environment.

    101983-screenshot-2021-06-03-162113.jpg
    101980-screenshot-2021-06-03-162133.jpg


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.

    0 comments No comments

  3. kasim mohamed 581 Reputation points
    2021-06-06T09:49:59.423+00:00

    Thanks for your response

    i dont want TSQL query.. i need insert statement with specific date range.

    Thanks


  4. kasim mohamed 581 Reputation points
    2021-06-07T09:18:53.407+00:00

    Yes cathyji,
    I have a date column

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.