Stored procedure EXEC vs sp_executesql difference?

Your sp_executesql SQL should probably be; DECLARE @SQL as nvarchar(128) = ‘select ‘ + @Columns + ‘ from ‘ + @TableName + ‘ where Status=@eStatus’ This will allow you to call sp_executesql with @eStatus as a parameter instead of embedding it into the SQL. That will give the advantage that @eStatus can contain any characters … Read more

Multiple Databases Vs Single Database with logically partitioned data [closed]

You’ll wish you had used separate databases: If you ever want to grant permissions to the databases themselves to clients or superusers. If you ever want to restore just one client’s database without affecting the data of the others. If there are regulatory concerns governing your data and data breaches, and you belatedly discover that … Read more

Sequence vs identity

I think you will find your answer here Using the identity attribute for a column, you can easily generate auto-incrementing numbers (which as often used as a primary key). With Sequence, it will be a different object which you can attach to a table column while inserting. Unlike identity, the next number for the column … Read more

Unable to delete the database user as the user is already logged in currently. error 15434

User can be deleted after killing the session by identifying the session_id of the user. SELECT session_id FROM sys.dm_exec_sessions WHERE login_name=”sagar” KILL 51 –51 is session_id here, you may get different id Now you can delete the login simply by executing the below query (or) by using sql server management studio options. DROP LOGIN ‘sagar’

SQL Server Connection Strings – dot(“.”) or “(local)” or “(localdb)”

. and (local) and YourMachineName are all equivalent, referring to your own machine. (LocalDB)\instance is SQL Server 2012 Express only. The other parts are depending on how you install – if you install with an instance name – then you need to spell that instance name out (SQL Server Express by default uses the SQLEXPRESS … Read more