0

I have code to get installed applications off the computer and want to add it into an SQL table. how do I do this and keep formatting ?

I would like it to be app1 newline app2 newline app3

ArrayOfApps = GetApps();

USE ComputerData INSERT INTO InstalledApps ( Apps ) VALUES (ArrayOfApps);"
4
  • 1
    Don't do this. Insert into separate rows and format only for presentation. Commented Jul 22, 2021 at 12:17
  • How do you suggest? My table is something like "computername, osname, installedapps" do you suggest multiple tables or something? Commented Jul 22, 2021 at 12:35
  • Hold only one piece of data per row/column. Probably the best is to remove "installedapps" and add a second table with (idoffirsttable, installedapp) which contains one row per program. Second best alternative would be inserting multiple rows, with the same name/os and different program. In any case, the formating is delegated to the visual layer. Commented Jul 22, 2021 at 12:42
  • Use a Table Valued Parameter, or SqlBulkCopy Commented Jul 22, 2021 at 14:05

1 Answer 1

1

Prepare your query like this

USE ComputerData 
INSERT INTO InstalledApps ( Apps ) VALUES (ArrayOfApps[0]),(ArrayOfApps[1]),(ArrayOfApps[2]);"
Sign up to request clarification or add additional context in comments.

1 Comment

If I was to display this afterwards would it appear like this : app1app2app3 or app1, app2, app3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.