Skip to content
Advertisement

Tag: tsql

Check in T-SQL whether certain value sets exist in a related table

I have following tables: User – userId, userName, … Settings – settingId, userId, settingKey, settingValue for example for userId = 123, I might have: Then for example how can I query for all users that have settingValue of “0” corresponding to settingKey of “allowClient” and settingValue of “1” corresponding to settingKey of “allowAccess”? Sometimes the settingKey and settingValue that I’m

What can I use instead of “Set Identity Insert On”?

I have stored procedure in SQL Server. In this procedure, I delete duplicate records and insert one unique records to table. When I insert new unique record I am using below script. Everthing is okey with this script but in the production SET IDENTITY_INSERT command needs to ALTER permission. Giving this permission should be dangerous so I can’t give this

Difference between dm_exec_sql_text vs dm_exec_input_buffer

As per Microsoft docs, dm_exec_sql_text returns the text of the SQL batch that is identified by the specified sql_handle while dm_exec_input_buffer returns information about statements submitted to an instance of SQL Server. I used DBCC INPUTBUFFER for getting the last executed SQL. But it seems both dm_exec_sql_text and dm_exec_input_buffer are replacement DBCC INPUTBUFFER. If this is the case then what

Advertisement