Friday, 23 April 2010

To Get The Result in One Lane

create table #tmp7 (col1 varchar(2000))
insert #tmp7 exec master..xp_cmdshell 'osql -E -w2000 -Q "exec sp_helplogins"'

select * from #tmp7

drop table #tmp7

Thursday, 15 April 2010

Linked Servers

Add Linked server and Logins !!

EXECUTE sp_addlinkedserver @server = N'BSQ-SQlxxxxx\xxxxx',
@srvproduct = '',
@provider = N'SQLOLEDB',
@datasrc = N'BSQ-SQLxxxxx\xxxxxx',
@catalog = N''
select * from sys.servers;
create logion Just for read access in Remote SERVER as SQL SERVER Authentication.
assign only db_datareader,public role and In userMapping only Databases you wanted to give access to read .
EXECUTE sp_addlinkedsrvlogin @rmtsrvname = 'BSQ-SQlxxxxx\xxxxx',
@useself = 'false',
@locallogin = 'DOMAIN\hem.p',
@rmtuser = 'HM_ReadONLY',
@rmtpassword = 'xxxx'
EXECUTE sp_droplinkedsrvlogin
@rmtsrvname = 'BSQ-SQlxxxxx\xxxxx' ,
@locallogin = 'DOMAIN\hem.p'

You can see your Linked server at SSMS-->Object Explorer --> Source sql Instance-->Server Objects --> Linked Servers.

That's It!!

Done!!

Cheers !!

Monday, 12 April 2010

SSRS Time And Total

To display date and time

= FORMAT(Globals!ExecutionTime, "MM/dd/yyyy hh:mm tt")

Only Time

= FORMAT(Globals!ExecutionTime, "hh:mm tt")


And To get

Total No Of Lines e.g. =Count(Fields!Account_ID.Value)

Sum Of Particular Field e.g. =sum(Fields!No_of_Times_Logged.Value)


To get Between WeekDays

="User Registered " & now().AddDays(-7).tostring("dd/MM/yyyy") & " - " & now().AddDays(-1).tostring("dd/MM/yyyy")

To get Between Months

="Oracle Core Idea Last Month Stats Rerport ( " & now().AddMonths(-1).Adddays(-(today.DAY-1)).tostring("dd/MM/yyyy") & " - " & today.Adddays(-(today.DAY-1)).tostring("dd/MM/yyyy") & " )"