question

kasimmohamed-6993 avatar image
0 Votes"
kasimmohamed-6993 asked Cathyji-msft answered

table data script file with date range

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

sql-server-generalsql-server-transact-sql
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @kasimmohamed-6993,

We have not received a response from you. Did the reply(s) could help you? If the response(s) helped, do "Accept Answer". If it is not, please let us know. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.

0 Votes 0 ·
Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered

Hi @kasimmohamed-6993,

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered

Hi @kasimmohamed-6993,

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.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

kasimmohamed-6993 avatar image
0 Votes"
kasimmohamed-6993 answered Cathyji-msft commented

Thanks for your response

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

Thanks

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @kasimmohamed-6993,

Did you have the date column in your tables? If you have, you can try the suggestion that I test in my environment.

0 Votes 0 ·
kasimmohamed-6993 avatar image
0 Votes"
kasimmohamed-6993 answered

Yes cathyji,
I have a date column

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.