0

I have a list of extended properties for all databases in an excel file. How can I import that into extended properties of each database in sql server.

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Jul 9 at 6:48

1 Answer 1

1

The TSQL script way of adding an Extended property is via sp_addextendedproperty

Slightly altered example from the documentation:

USE AdventureWorks2022;
GO

EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = 'Postal code is a required column.',
    @level0type = 'SCHEMA', @level0name = N'Person',
    @level1type = 'TABLE', @level1name = N'Address',
    @level2type = 'COLUMN', @level2name = N'PostalCode';
GO

While you could create the statement in Excel through string concatenation that would be mainly useful for a single database only.

If you have multiple databases you might be better off using some programming language outside of SQL like PowerShell (perhaps with dbatools module) and looping through the rows while passing the values to the proc above.

2
  • Probably the ImportExcel module helps OP here too 😜 Commented Jul 8 at 18:39
  • Thanks. How can I import information into the extended properties of each database from xlsx file by query. I have 7 property for each database that I wanna enter to extended properties.
    – Ramon
    Commented Jul 10 at 5:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.