Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chadsharp
Engaged Sweeper
I am trying to utilize the custom fields in Lansweeper. I am trying use the follow sql to update the custom1 field if the server name is server01. I'm not sure what I'm doing wrong.

use lansweeperdb
Update dbo.tblAssetCustom
set Custom1 = 'test'
Select tblAssets.AssetID, tblassets.AssetName, tblAssetCustom.AssetID, tblAssetCustom.Custom1
from tblAssets
Inner Join tblAssetCustom on tblAssets.AssetID = tblAssetCustom.AssetID
where tblassets.AssetName = 'Server01'

This script does not do what I intended, it updates all of the fields in tblAssetCustom when I only want to update where tblassets.AssetName = 'Server01'

The reason I am wanting to do this is I have a powershell script that I wrote that will read a .cvs file that is an export from the inventory system that lansweeper replaced and I need to be able to traverse that file and only update records based on specific conditions.

Any assistance would be greatly appreciated.

thanks
Chad
1 ACCEPTED SOLUTION
RCorbeil
Honored Sweeper II
Maybe something like this?
UPDATE
tblAssetCustom
SET
Custom1 = 'test'
FROM
tblAssetCustom
INNER JOIN tblAssets ON tblAssets.AssetID = tblAssetCustom.AssetID
WHERE
tblAssets.AssetName = 'Server01'

View solution in original post

2 REPLIES 2
chadsharp
Engaged Sweeper
That did the trick. Thank you.
RCorbeil
Honored Sweeper II
Maybe something like this?
UPDATE
tblAssetCustom
SET
Custom1 = 'test'
FROM
tblAssetCustom
INNER JOIN tblAssets ON tblAssets.AssetID = tblAssetCustom.AssetID
WHERE
tblAssets.AssetName = 'Server01'

Reports & Analytics

Ask about reports you're interested in and share reports you've created. Subscribe to receive daily updates of reports shared in the Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now