திங்கள், 8 ஜூலை, 2013

ssrs: the variable name has already been declared -- when working with temp tables


   1: declare @Marcus table
   2:     (
   3:         resourceid nvarchar(10),
   4:         name nvarchar(255)
   5:     )
   6:  
   7: insert into @marcus
   8: select resourceid,name0 from v_r_system
   9:  
  10: select * from @marcus

when executed in sql server management studio, the query runs as expected.  it just grabs resourceid and system name, puts them into a temporary table, and draws them right back out.  however, when executed in bids (business intelligence development studio), you receive the error stating "the variable name has already been declared. variable names must be unique within a query batch or stored procedure."
 discovered that while windows is decidedly case insensitive, sometimes it changes its mind.  in visual studio (bids, etc) it appears that the case used for variables with respect to temporary tables is sensitive!
so, back to the simple query, here's the revised change.  just keep your case the same.
   1: declare @Marcus table
   2:     (
   3:         resourceid nvarchar(10),
   4:         name nvarchar(255)
   5:     )
   6:  
   7: insert into @Marcus
   8: select resourceid,name0 from v_r_system
   9:  
  10: select * from @Marcus

வியாழன், 4 ஜூலை, 2013

Zip the file using VB.net with Password

 Dim ret As Long
ret = Shell("C:\Program Files\WinRAR\rar a -ap C:\ZipFileSave\test_22.zip -psrini D:\Report")


Password :-> srini
source folder :->D:\Report
Destination folder :->C:\ZipFileSave
Filename :test_22.zip


செவ்வாய், 2 ஜூலை, 2013

Send Email from SQL server Table format


How to access linked server user defined functions in SQL Server

Select * from Openquery( Linked server name ,'select * from [TESTDB].[dbo].[tblname] where id=[TESTDB].[dbo].GETID(600)')

Trying to save Excel vb.net - Exception from HRESULT: 0x800A03EC


 .ActiveWorkbook.SaveAs(path2)
Instead of saving file like above , save like below.

 .ActiveWorkbook.Saved = True
 .ActiveWorkbook.SaveCopyAs(path2)

திங்கள், 10 ஜூன், 2013

create crystal Report using Excel File (Data Source)

1) Create a sample Excel file - only few records
2) Created a System ODBC connection pointing this excel file say "TEST1"
3) Opened A Blank Crystal Report
4) Create a New connection
5) Select ODBC RDO
6) Create new connection and selected the newly created SYSTEM DSN "TEST1"
7) Right Click on the connection (created)
8) Select "options" in window
9) it will show multiple check boxes for different options.
10) Select the checkbox for System Tables under Data Explorer.
11) click Ok & Exit
12) Refresh the ODBC connection by right clicking it.
13) you should be able to see the selected excel sheets in the ODBC connection.

திங்கள், 3 ஜூன், 2013

Send Email from Sql server With Attachment

IF OBJECT_ID('AgeNotfi') IS NOT NULL exec ('DROP TABLE AgeNotfi') select code, name, convert(varchar(20), birth_date,101) as birth_date into AgeNotfi from View_Elapco_prob_end_date where birth_date=convert(date,convert (Varchar(12), GETDATE(),111),111) insert into AgeNotfi Select 'Code' as Code, 'Name' [Name], 'Birth Date' as [Birth Date] select * from AgeNotfi DECLARE @EXEQRY VARCHAR(8000) DECLARE @SQLSQRY VARCHAR(200) DECLARE @FILENAME VARCHAR(250) SET @FILENAME='C:\BCP\AgeAbove64_'+ CONVERT(VARCHAR(12),GETDATE(),105)+ '.csv' set @SQLSQRY = ' select * from [HR].[DBO].AgeNotfi' SELECT @EXEQRY='bcp "'+ @SQLSQRY +'" queryout '+ @FILENAME +' -c -t, -Usa -Pwork@elapco -S'+ @@servername exec master.[dbo].xp_cmdshell @EXEQRY DECLARE @Message VARCHAR(2000), @Subject VARCHAR(500) SET @Message = ' Dear Sir/Madam
Please find the attached File.This is an auto generated email.
' SET @Subject = ' Age Above 65 Notification' exec msdb..sp_send_dbmail @recipients='sri@gmail.com', @subject = @subject,@body = @message,@File_Attachments = @FileName, @body_format='HTML'