Archive

Posts Tagged ‘sysdtslog90’

TSQL Interview Questions – Part 4

July 1, 2011 4 comments

Next part of TSQL Interview Questions, contd. from my previous post.

76. What are Running totals and how would you calculate them? Create a single SQL statement starting with SELECT or ;WITH.
http://sqlwithmanoj.wordpress.com/2011/07/04/calculating-running-totals/

77. What are the various SSIS logging mechanisms?
– Text file
– SQL Server Profiler
– SQL Server
– Windows Event Log
– XML File
MS BOL link: http://msdn.microsoft.com/en-us/library/ms140246.aspx

78. On which table the SSIS SQL Server logs are stored?
On 2005 its sysdtslog90 & on 2008 its sysssislog.
More on SSIS logging on: http://sqlwithmanoj.wordpress.com/2011/06/15/logging-in-ssis-using-sql-server-log-provider/

79. Reverse a String value without using REVERSE() function and WHILE loop. Should be a single SQL statement/query.
http://sqlwithmanoj.wordpress.com/2011/08/18/reverse-a-string-without-using-tsqls-reverse-function/

80. What is the use of BCP utility in SQL Server and how will you use it?
http://sqlwithmanoj.wordpress.com/2011/09/09/bcp-in-out-queryout-the-bcp-util/

81. Is there any difference between Excel Source in SSIS 2005 & 2008?
http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/ea770da2-6f0c-41c4-8093-52b5df73f460/#4267c1f1-74a0-4e2c-b5a4-e2909bf4e5f4

82. Difference between Bookmark lookup & RID lookup?

83. How nested transactions behave?
Here is a scenario:
I have a transaction T and inside this there are 2 transactions T1 AND T2.
If TRANSACTION T2 fails then what happens to transaction T and T1

84. How will you check if a stored procedure with 500 line of code is running very slow? What steps will you take to optimize it?

85. New features in SQL Server 2005 compared to SQL Server 2000 you’ve worked with.
PIVOT, UNPIVOT, Ranking functions (row_number, rank, dense_rank, ntile), CTEs, Grouping sets (ROLUP, CUBE), Intersect, Except, OUTPUT clause, Merge statement, Try-Catch, BIDS (SSIS, SSRS, SSAS), CLR, SMO.
New datatypes: XML, VARCHAR(max), NVARCHAR(max), VARBINARY(max) deprecating the TEXT, NTEXT AND IMAGE datatypes.
XML  indexes.
Database (SMTP) mail, SSMS, DMVs, Express Edition, Service Broker, Data Encryption, MARS

86. How will you copy unique records from duplicates in source to destination in SSIS?

87. What transformation will you use to concatenate First name and Last name in SSIS?

88. What do you mean by selectivity of a column/table?
The selectivity is what goes with the cardinality concept. The “cardinality” refers to the number of “distinct” values, as in the set theory so, take a column “SEX”.  The possible values are “male” and “female” (ignoring for the moment other possible values like “unknown” or even “other”) … so, your cardinality for that column would be 2, no matter how many rows you have in that table.

The selectivity is the “number of rows” / “cardinality”, so if you have 10K customers, and search for all “female”, you have to consider that the search would return 10K/2 = 5K rows, so a very “bad” selectivity.

The column for the primary key on the other side is “unique”, and hence the cardinality is equal to the number of rows, by definition.  So, the selectivity for searching a value in that column will be 1, by definition, which is the best selectivity possible.

89. Difference between EXISTS & IN, which one gives good performance?

90. What output will “SELECT 1/2″ statement give?
0, it will give zero.

91. What is Database Partitioning?
This involves 4 steps:
1. Create Database with different file groups
2. Create Partition Function
3. Create Partition Scheme
4. Create Partitioned Table or Index

92. What is the use of NOLOCK option?

93. How many types of recovery models are available for a database?
1. Simple
2. Bulk logged
3. Full

94. How many types of temporary tables are there in SQL Server?
– Local Temp tables (#)
– Global temp tables (##)
– Table variables (@)

95. In how many ways you can get a table’s row count?

--// 1. Using COUNT(*)
Select count(*) from Person.Contact

--// 2. using COUNT(1)
select count(1) from Person.Contact

--// 3. Using SUM() aggregate function
select sum(1) from Person.Contact

--// 4. Using sysindexes view
select object_name(id), rows from sys.sysindexes where object_name(id) = 'Contact' and indid<2

--// 5. Using sp_spaceused system SP
exec sp_spaceused 'Person.Contact' 

--// 6. Using DBCC CHECKTABLE function
DBCC CHECKTABLE('Person.Contact') 

--// Note: Before running 5 & 6 you may need to run this script:
DBCC UPDATEUSAGE ('AdventureWorks','Person.Contact') WITH COUNT_ROWS

Reference

96. In how many ways you can select distinct records from a table?

97. In how many ways you can select top 1 row?

98. What are the new features introduced in SQL Server 2008 R2?

99. What are the new features added SQL Server 2012 (Denali)?

100. What new feature has been added to TRY-CATCH construct?
… more questions on next post Part-5.

Logging in SSIS… using SQL Server Log Provider

June 15, 2011 3 comments

As per MS BOL SSIS provides a diverse set of log providers, and gives you the ability to create custom log providers. The Integration Services log providers can write log entries to text files, SQL Server Profiler, SQL Server, Windows Event Log, or XML files. This help in implementing logging in SSIS packages. With logging you can capture run-time information about a package, helping you audit and troubleshoot a package every time it is run.

Following are the different log providers:
1. Text File
2. SQL Server Profiler
3. SQL Server
4. Windows Event
5. XML File

Here we will see how can we use the SQL Server log provider (#3 above), which writes log entries to the sysssislog table in a SQL Server database.
Please note in 2005 the logs are stored in sysdtslog90 table. In 2008 the table name is changed to sysssislog.

Following are the easy steps one can follow to configure logging:

1. Create a SSIS package, as shown below are the 2 Execute SQL tasks. To enable logging goto menu, select SSIS-> Logging…

2. On this new window select the Provider Type as “SSIS log provider for SQL Server”, click Add.

3. The log provider will be added, select by checking the check box. Now provide the connection where the log table should get created.

4. Switch to the Details tab and select the events you want to log and audit. Click OK, save your SSIS package and your logging is enabled.

5. After this run your package and switch to  SSMS and check on object explorer that the table sysdtslog90 has been created on the database you added as a connection. Now you can query the sysdtslog90 table where the logs are stored.

select * from FROM [AdventureWorks].[dbo].[sysdtslog90]

The sysdtslog90 table contains following columns listed in the query below. All are self explanatory, one can also check the links at the end of the post to get more info about them.

SELECT [id], [event], [computer], [operator], 1, --,[sourceid], [executionid],
      [starttime],[endtime],[datacode], [databytes], [message]
FROM [AdventureWorks].[dbo].[sysdtslog90]

Links on SSIS Log Providers & Implementing them:
http://msdn.microsoft.com/en-us/library/ms140246.aspx
http://msdn.microsoft.com/en-us/library/ms138020.aspx

sysdtslog90

Follow

Get every new post delivered to your Inbox.

Join 388 other followers