hidrau
asked on
how to make a condiction with mssql version?
Hello guys
I have a script that I need to run in my clients but some of them have the mssql 2005 and others mssql 2014
I need to make something this:
if mssql_version = 2005 begin
end else if mssql_version = 2008 begin
end else if mssql_version = 2014 begin
end;
Thanks
alexandre
I have a script that I need to run in my clients but some of them have the mssql 2005 and others mssql 2014
I need to make something this:
if mssql_version = 2005 begin
end else if mssql_version = 2008 begin
end else if mssql_version = 2014 begin
end;
Thanks
alexandre
please provide full code...Please provide the script also.
ASKER
For examplo, this code doesn't work in 2014, then I need to change it to another way. But for 2008 and 2005 it works fine.
if exists (select * from Master..sysdatabases where Name = '<BANCO>') begin
use Hermes;
exec sp_dboption 'Hermes', 'trunc. log on chkpt' , 'on';
exec sp_dboption 'Hermes', 'select into/bulkcopy', 'on';
exec sp_dboption 'Hermes', 'ANSI null default' , 'on';
--removido o autoshrink para não alterar o tamanho do banco de dados
exec sp_dboption 'Hermes', 'autoshrink' , 'off';
exec sp_dboption 'Hermes', 'auto update statistics', 'off';
--trunca as informações do arquivo de log para reduzir o tamanho
if dbo.fnSQL_VersaoMaiorSQL() < 10 begin
exec('BACKUP LOG Hermes WITH TRUNCATE_ONLY');
use master;
if (select value from sysconfigures where config = 106) < 50000 begin
exec sp_configure 'min server memory',20;
exec sp_configure 'locks',50000;
reconfigure with override;
end;
end;
use Hermes;
end;
go
Please try like--
IF mssql_version = 2005 or mssql_version = 2008
BEGIN
if exists (select * from Master..sysdatabases where Name = '<BANCO>') begin
use Hermes;
exec sp_dboption 'Hermes', 'trunc. log on chkpt' , 'on';
exec sp_dboption 'Hermes', 'select into/bulkcopy', 'on';
exec sp_dboption 'Hermes', 'ANSI null default' , 'on';
--removido o autoshrink para não alterar o tamanho do banco de dados
exec sp_dboption 'Hermes', 'autoshrink' , 'off';
exec sp_dboption 'Hermes', 'auto update statistics', 'off';
--trunca as informações do arquivo de log para reduzir o tamanho
if dbo.fnSQL_VersaoMaiorSQL() < 10 begin
exec('BACKUP LOG Hermes WITH TRUNCATE_ONLY');
use master;
if (select value from sysconfigures where config = 106) < 50000 begin
exec sp_configure 'min server memory',20;
exec sp_configure 'locks',50000;
reconfigure with override;
end;
end;
use Hermes;
end;
END;
ELSE
BEGIN
END;
ASKER
Does this exist "mssql_version" ?
Mensagem 207, Nível 16, Estado 1, Linha 1
Invalid column name 'mssql_version'.
Mensagem 207, Nível 16, Estado 1, Linha 1
Invalid column name 'mssql_version'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks friend for your help
ASKER
it was to explit the point and it didn't happen. :(
Sorry Pawn :((
Sorry Pawn :((
No problem, you can ask the moderators to open the question for you and then you can re close the question.
There is a report question link at the top of the question. You need to click on that and then you can ask the mods to open this for you.
There is a report question link at the top of the question. You need to click on that and then you can ask the mods to open this for you.
ASKER
thansk for the clue Pawan
ASKER
Thanks a lot for your help