Retrieving id of inserted record: What to use @@IDENTITY or SCOPE_IDENTITY() or OUTPUT

Hi guys, This seems very basic information but need to know properly. Issue: I need to find out or have the id of the records which I inserted in table. Analysis: This requirement seems very simple but there could be various cases where you would not get the correct id just by using @@IDENTITY function. Think …

Continue reading ‘Retrieving id of inserted record: What to use @@IDENTITY or SCOPE_IDENTITY() or OUTPUT’ »

The Story of Precision, Scale, and Length in SQL Server

Hi guys, Did you ever faced issues with BIG mathematical figures – related to either overflow or any  other arithmetic errors. This may be applicable to SQL arithmetic operations or arithmetic  operations you do with SQL table in SSIS etc. Well, check 1 more time, if you have any issues in your database design related …

Continue reading ‘The Story of Precision, Scale, and Length in SQL Server’ »

MSSQL: Find total records of each Table in given Database

hi guys, i wanted to do a quick post on how you can find total number of records in each table of the database. here is the script you can use: USE <Your Database Name> GO ;WITH CTE_DATABASETABLESIZE (DATABASENAME, SCHEMANAME, TABLENAME, TOTALROWS) AS ( SELECT  DB_NAME(), SCHEMA_NAME(SO.UID), SO.NAME, SI.ROWS FROM  SYSOBJECTS SO  INNER JOIN SYSINDEXES …

Continue reading ‘MSSQL: Find total records of each Table in given Database’ »

Fastest way to find-out/understand relationships between tables in MS SQL Database

Hi guys, For most of the BI developers, getting BI related tasks (SSAS, SSIS, SSRS etc.) from multiple teams in company is very common. So in this situation, developer completes a task(s) for one team and goes to another team for different task(s). Once you go to the team for their requirements … lets say …

Continue reading ‘Fastest way to find-out/understand relationships between tables in MS SQL Database’ »