Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fafastrungen
Starting Member
5 Posts |
Posted - 2007-07-26 : 03:11:13
|
| Hi, I need to concatenate the xp_getnetname function with a string. When I execute xp_getnetname I get:"ITANIUM01"and I need to concatenate it with the next string:"\\10.50.100.1\BACKUPS\"to get something like this:"\\10.50.100.1\BACKUPS\ITANIUM01"so, how can I accomplish this ?Thanks in advance. |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2007-07-26 : 04:41:58
|
| you cannot get the output of a procedure concatenated with a string. However, you can use an alternative by getting the output in a table type variable and concatenate it with string value. |
 |
|
|
fafastrungen
Starting Member
5 Posts |
Posted - 2007-07-26 : 06:34:41
|
quote: Originally posted by shallu1_gupta you cannot get the output of a procedure concatenated with a string. However, you can use an alternative by getting the output in a table type variable and concatenate it with string value.
I knew that I can insert the result of the function into a table declared as variable, but what I was trying to do is get everything in one line, something like this:Select "\\10.50.100.1\BACKUPS\" + xp_getnetnameThanks for your answer, I know now that I must find another way. |
 |
|
|
yoshidamiki
Starting Member
1 Post |
Posted - 2007-08-30 : 03:07:50
|
drop table #tmpcreate table #tmp([Server Net Name] varchar(64))insert into #tmp exec xp_getnetname--select * from #tmpdeclare @t as nvarchar(64)set @t=(select [Server Net Name] from #tmp)print '\\10.50.100.1\BACKUPS\' + @tSelect '\\10.50.100.1\BACKUPS\' + @t |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-30 : 03:55:14
|
xp_getnetname is undocumented.I think you should go for the registry read method, since now and then some undocumented methods are removed.DECLARE @test varchar(20)EXEC master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Test', 'TestValue', @test OUTPUTSELECT @test E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-04 : 09:17:24
|
[code]CREATE VIEW dbo.vwDatabaseInformationASSELECT 'MachineName' AS PropertyName, SERVERPROPERTY('MachineName') AS PropertyValue UNION ALLSELECT 'ServerName', SERVERPROPERTY('ServerName') UNION ALLSELECT 'InstanceName', SERVERPROPERTY('InstanceName') UNION ALLSELECT 'Edition', SERVERPROPERTY('Edition') UNION ALLSELECT 'ProductVersion', SERVERPROPERTY('ProductVersion') UNION ALLSELECT 'ProductLevel', SERVERPROPERTY('ProductLevel') UNION ALLSELECT 'EngineEdition', SERVERPROPERTY('EngineEdition') UNION ALLSELECT 'ComputerNamePhysicalNetBIOS', SERVERPROPERTY('ComputerNamePhysicalNetBIOS')[/code]SELECT PropertyValue FROM dbo.vwDatabaseInformation WHERE PropertyName = 'MachineName' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-04 : 09:18:51
|
And in your caseSELECT '\\10.50.100.1\BACKUPS\' + SERVERPROPERTY('MachineName')orSELECT '\\10.50.100.1\BACKUPS\' + PropertyValueFROM dbo.vwDatabaseInformationWHERE PropertyName = 'MachineName' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|