4

The inserts of a certain table(s) can be generated by using SQL Server Management Studio by right clicking on the database -> tasks -> generate scripts, choosing the tables and finally selecting data only. However the table gets bigger with time and I need only the inserts with a certain condition which would only return only a part of the data in that table.

Example: there is a table

FlightTickets
(
    TicketId(PK), 
    BuyerId(FK to buyers), 
    FlightId(FK to Flights)
)

and I only need the insert scripts with condition FlightId = 12345.

Is it possible to be done in SQL Server Management Studio or do I have to write some in C# to deal with that?

Andrius Naruševičius
  • 8,348
  • 7
  • 49
  • 78
  • 1
    Having the same problem here. I need to do the basic task of generating scripts from a table. Same as the utility at database -> tasks -> generate scripts, but I need to specify a where clause to get lesser results. – wenzzzel Mar 07 '19 at 15:40

1 Answers1

6

You can try database -> tasks --> Import Data --> [then choose source and destination]--> [write a query to specify the data to transfer] option --> then write your query with filter [ where flightid=12345]

ram_sql
  • 404
  • 2
  • 9