Skip to content
Advertisement

Tag: sql

Sync columns(without data) in multiple tables

I have multiple tables inside my database: Is there a way to keep the columns of all the tables in sync with each other? What I mean is that when I add a new column named ‘⁣last-edit’ inside the first table, this column will duplicate to all the other tables. But the data inside the columns will only be unique

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

Copy data on parent and child table

I have two database tables. What I need to do is to copy specific data from one storage to another, but also keep the mapping to the photos. First part I can do easily writing but after that newly inserted items does not have photos. Note, that document_id field is unique for not copied items. Answer Assuming id columns are

How to wirte an select with forigin keys and such

I am about to setup a sql db, not decided yet for mysql, mariadb or postgresql. But before that I have set up my sql script to create the tables I need. First I need help with a sanity check, can you without me see what I am setting up here? Second, the thing I am struggeling with now is

Perform Calculation in MongoDb Query

Supposed I have the collections that contain Event type Product View water_heater View water_heater Purchase water_heater View television View television View television Purchase television There are two types of fields in the first column, (views and purchase) The second column contains different kinds of products. The above data has been imported as a collection in MongoDB database. I want to

Db2: perfomant way to check if item exists

what will be the fastest way to check if a specific item exists in table or not. I am evaluating the result of this select, but will be there a faster and Performance way? Answer This depends on what you want to do with the result. It’s generally not recommended to use aggregate functions, since you don’t need to scan

Count the no of columns with same value in SQL

I have a database MySQL table as following Id Column1 Column2 Column3 First value1 value1 value2 Second value2 value1 value2 I want to retrieve the count of value1 for the row with id First example table as follows Id COUNT(value1) First 2 I searched on google but found posts only regarding counting in one specific column. Can anyone help me

Advertisement