I am trrying to create logins to a few database servers, i tried two scripts, some of them work on a particualr server while the second works on some servers.
here are the scripts
if not exists(select * from sys.server_principals where name = ABC\apps_dev')
CREATE LOGIN [ABC\apps_dev] FROM WINDOWS
It gives me an error on some database servers
Line 3: Incorrect syntax near 'LOGIN'.
I tried this on the server it fails and this works on some server
if not exists(select * from syslogins where name = 'ABC\apps_dev')
exec sp_grantlogin 'ABC\apps_dev'
I would like to know why these versions work on some servers, is this a versioning issue and how can I verify which version is used.