Wednesday, March 21, 2012
Parse output from xp_cmdshell
E:\NewOrleans\*FULL.BAK') to a variable. I would like to test each line of
the output variable to see if (wildcard.BAK) exist. If (wildcard.BAK) exis
t
I append this code to my existing script.
Please help me create this script.
Thanks,
-- directory full backup listing
Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK'
Output from (Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK')
Volume in drive E is NWORLBD01A Dumps
Volume Serial Number is DRV-73B6
NULL
Directory of E:\NewOrleans
NULL
05/12/2005 12:57 AM 168,988,440,064 STARDEV_db_200505152100.BAK
1 File(s) 168,968,064 bytes
0 Dir(s) 295,359,264 bytes free
NULLJoe K. wrote:
> I would like to write the output from (Exec master..xp_cmdshell 'dir
> E:\NewOrleans\*FULL.BAK') to a variable. I would like to test each
> line of the output variable to see if (wildcard.BAK) exist. If
> (wildcard.BAK) exist I append this code to my existing script.
> Please help me create this script.
> Thanks,
> -- directory full backup listing
> Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK'
>
> Output from (Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK')
> Volume in drive E is NWORLBD01A Dumps
> Volume Serial Number is DRV-73B6
> NULL
> Directory of E:\NewOrleans
> NULL
> 05/12/2005 12:57 AM 168,988,440,064 STARDEV_db_200505152100.BAK
> 1 File(s) 168,968,064 bytes
> 0 Dir(s) 295,359,264 bytes free
> NULL
Create Table #output (output varchar(1000))
insert into #output
Exec master..xp_cmdshell 'dir C:'
Select * from #output
drop table #output
David Gugick
Imceda Software
www.imceda.com|||Look at this example:
create table #ipconfig(line varchar(2000))
insert into #ipconfig
execute xp_cmdshell 'ipconfig.exe'
select line from #ipconfig
drop table #ipconfig
YOu can "parse" that table with
Select * form #ipconfig where line like '%Something%'
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Joe K." <Joe K.@.discussions.microsoft.com> schrieb im Newsbeitrag
news:4D55228E-D4E2-4EA0-A533-1B4556C5232F@.microsoft.com...
> I would like to write the output from (Exec master..xp_cmdshell 'dir
> E:\NewOrleans\*FULL.BAK') to a variable. I would like to test each line
> of
> the output variable to see if (wildcard.BAK) exist. If (wildcard.BAK)
> exist
> I append this code to my existing script.
> Please help me create this script.
> Thanks,
> -- directory full backup listing
> Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK'
>
> Output from (Exec master..xp_cmdshell 'dir E:\NewOrleans\*FULL.BAK')
> Volume in drive E is NWORLBD01A Dumps
> Volume Serial Number is DRV-73B6
> NULL
> Directory of E:\NewOrleans
> NULL
> 05/12/2005 12:57 AM 168,988,440,064 STARDEV_db_200505152100.BAK
> 1 File(s) 168,968,064 bytes
> 0 Dir(s) 295,359,264 bytes free
> NULL
>|||Create temp table and change my path to you path and it will give you
directory returned data in a table then you extract the peaces you need.
Create TABLE #temp
(
data nvarchar (1000)
)
Insert #temp
Exec master..xp_cmdshell 'dir \\server\backup\sql\FULL_Backup\*(FULL)*
.BKP'
select * from #temp
"Jens Sü?meyer" wrote:
> Look at this example:
> create table #ipconfig(line varchar(2000))
> insert into #ipconfig
> execute xp_cmdshell 'ipconfig.exe'
> select line from #ipconfig
> drop table #ipconfig
>
> YOu can "parse" that table with
> Select * form #ipconfig where line like '%Something%'
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Joe K." <Joe K.@.discussions.microsoft.com> schrieb im Newsbeitrag
> news:4D55228E-D4E2-4EA0-A533-1B4556C5232F@.microsoft.com...
>
>
Saturday, February 25, 2012
parameterizing multi valued parameter in data set
Hi,
I am creating a data set for a ROLAP report which executes a dynamic SQL using EXEC. I am finding problems parameterizing multi-valued report parameters in the SQL being executed through EXEC.
To consider a sample code:
EXEC('select * from country where country_key in ('+@.country+')')
where @.country is a multi-valued report parameter.
Regards,
Emil
google is a wonderful thinghttp://groups.google.co.uk/group/microsoft.public.sqlserver.reportingsvcs/browse_frm/thread/9d9739713fe89f5f/11b4fc22ce2e9e0b?lnk=st&q=multi+value+parameter+%22reporting+services%22&rnum=3#11b4fc22ce2e9e0b|||
Hi,
i am facing similar problem. I was trying dynamic SQL for the performance of the report.
But got stuck on multivalued parameter......
For me
Declare @.sql varchar(4000), @.rcc varchar(4000)
set @.rcc='a'; -- now if more than one value will be passed to it, this query will fail, it will execute but return nothing.
select @.sql='SELECT * FROM abc '
select @.sql=@.sql + 'where abc_column in (''' + @.rcc + N''')'
Exec( @.sql)
I am not sure creating a function and using it to split the parameter values finally result as a plus or minus to the performance.
If any one has any other way of doing this, Pls help.
|||and did you bother reading the link?|||
Try this
create another parameter new_param_country which is single valued
make it hidden
give value as
="'" & Join(Parameters!country.Label, "', '") & "'"
Give the same expression for default value too
For eg:- if the countries selected are FRANCE, INDONESIA and ICELAND, the value of the new parameter will be 'FRANCE', 'INDONESIA', 'ICELAND' which is a string
Use this parameter in the dataset instead of the multivalued parameter.
Regards,
Meenu
|||
Thanks a lot Meenu. :-)
Works fine for me. Just did a little change to the expression
=Join(Parameters!country.Value, ", ")
as I needed only value.
Regards,
Emil
|||This is exactly what I've been looking for to put all if the multi-value parameter values in the page header.
Thanks!
-Marianne
parameterizing multi valued parameter in data set
Hi,
I am creating a data set for a ROLAP report which executes a dynamic SQL using EXEC. I am finding problems parameterizing multi-valued report parameters in the SQL being executed through EXEC.
To consider a sample code:
EXEC('select * from country where country_key in ('+@.country+')')
where @.country is a multi-valued report parameter.
Regards,
Emil
google is a wonderful thinghttp://groups.google.co.uk/group/microsoft.public.sqlserver.reportingsvcs/browse_frm/thread/9d9739713fe89f5f/11b4fc22ce2e9e0b?lnk=st&q=multi+value+parameter+%22reporting+services%22&rnum=3#11b4fc22ce2e9e0b|||
Hi,
i am facing similar problem. I was trying dynamic SQL for the performance of the report.
But got stuck on multivalued parameter......
For me
Declare @.sql varchar(4000), @.rcc varchar(4000)
set @.rcc='a'; -- now if more than one value will be passed to it, this query will fail, it will execute but return nothing.
select @.sql='SELECT * FROM abc '
select @.sql=@.sql + 'where abc_column in (''' + @.rcc + N''')'
Exec( @.sql)
I am not sure creating a function and using it to split the parameter values finally result as a plus or minus to the performance.
If any one has any other way of doing this, Pls help.
|||and did you bother reading the link?|||
Try this
create another parameter new_param_country which is single valued
make it hidden
give value as
="'" & Join(Parameters!country.Label, "', '") & "'"
Give the same expression for default value too
For eg:- if the countries selected are FRANCE, INDONESIA and ICELAND, the value of the new parameter will be 'FRANCE', 'INDONESIA', 'ICELAND' which is a string
Use this parameter in the dataset instead of the multivalued parameter.
Regards,
Meenu
|||
Thanks a lot Meenu. :-)
Works fine for me. Just did a little change to the expression
=Join(Parameters!country.Value, ", ")
as I needed only value.
Regards,
Emil
|||This is exactly what I've been looking for to put all if the multi-value parameter values in the page header.
Thanks!
-Marianne
Monday, February 20, 2012
Parameterized SSIS Packeges
How i can create parameterized sql query .This is my basic idea to implement.
select * from dimemployee
where name = ?
or
exec proc sp_para_employee ?
how can i pass expocit parameter (that means when i run the package that time it should ask me or when i pass the parameter should execute ,satisfy atleast one xondition ).rf any one have script please provide me because i tried all angles using books on line and other resorces.
did you try using the execute sql task, mapping the parameter to a variable?|||JSR2005 wrote:
How i can create parameterized sql query .This is my basic idea to implement.
select * from dimemployee
where name = ?
or
exec proc sp_para_employee ?
how can i pass expocit parameter (that means when i run the package that time it should ask me or when i pass the parameter should execute ,satisfy atleast one xondition ).rf any one have script please provide me because i tried all angles using books on line and other resorces.
How hard did you look?
Execute SQL Task
(http://www.sqlis.com/default.aspx?58)
-Jamie
|||thank you it is working fine