Category "sql"

Could not drop object 'dbo.Table1' because it is referenced by a FOREIGN KEY constraint

Even though I am removing and trying to drop table, I get error, ALTER TABLE [dbo].[Table1] DROP CONSTRAINT [FK_Table1_Table2] GO DROP TABLE [dbo].[Table1] GO

Get full tree of parent/child relationships in mysql of any node in the tree with all parents

Example data: +----+-------+----------+ | org_id | Name | ParentID | +----+-------+----------+ | 1 | Org1 | 2 | | 2 | Org2 | NULL | | 3 | Org3

How to parse the following JSON to retrieve the name of the item in snowflake sql?

[ { "itemId": "HWKDVCXKU5", "name": "A", "quantity": 1.000000000000000e+00, "storeId": 1.150192000000000e+06, "type": "structure" },

How does Multiple Active Result Set (MARS) work in SQL Server?

Just wondering if someone could explain how Multiple Active Result Set (MARS) works in SQL Server as it is not very clear on the MSDN site. (A) On a MARS conn

JPA (Hibernate) Native Query for Prepared Statement SLOW

Having strange performance issue using Hibernate 3.3.2GA behind JPA (and the rest of the Hibernate packages included in JBoss 5.) I'm using Native Query, and a

SQL Server unpivot multiple columns

I'm trying to pivot a table around it's many columns to get to 3 columns (pivot, column name, value) so for example: name | age | gender ------+-------+--

Best way to select random rows PostgreSQL

I want a random selection of rows in PostgreSQL, I tried this: select * from table where random() < 0.01; But some other recommend this: select * from table

How To Set Server Output On in DataGrip

How Can I "set server output" on in Jetbrains DataGrip IDE? I am able to do this in SQL Developer and run the SQL script successfully. The same script I try to

Getting output of MS stored procedure on php call

I am using the sqlsrv ms drivers for php, which work fine (tested with normal queries). I have also tested it with running a stored procedure to update a table

Function Based Index not improving query performance

I have created view and in this view i have added the below case statement which i need and for which i already create exactly the function based index. The vie

How do I loop through an MS SQL database with VB.NET?

I'm trying to implement the following php code in visual basic. I wrote it in PHP because I knew I could do what I wanted to in that language, but I can't for t

how to get Arabic Month Names in sql?

I am trying hard to get the 12 months names in Arabic , I tried a lot but nothing work. any help ?

Why time format is changing in Azure Databricks

I have a file with a timestamp with time format as 2017-01-20 16:53:05.212 (yyyy-MM-dd HH:mm:ss.SSS). I have uploaded this file to Azure data lake gen 2 and acc

List the details of employee ,department with a reference column

Here I have 2 tables, Employee and Department, and the data as follows. Employee: Empid Empname Deptid salary ----------------------------------------- 1

Create PostgreSQL ROLE (user) if it doesn't exist

How do I write an SQL script to create a ROLE in PostgreSQL 9.1, but without raising an error if it already exists? The current script simply has: CREATE ROLE

SQL Server stored procedures don't refresh even after refresh

Anytime I'm editing and debugging a SQL Server stored procedure, I'll make the changes, then refresh all along the line. I'll refresh folders: Stored Procedures

Select last n rows without use of order by clause

I want to fetch the last n rows from a table in a Postgres database. I don't want to use an ORDER BY clause as I want to have a generic query. Anyone has any su

Generate random int value from 3 to 6

Is it possible in Microsoft SQL Server generate random int value from Min to Max (3-9 example, 15-99 e.t.c) I know, I can generate from 0 to Max, but how to inc

sequelize destroy record with join

In my model there is a Users table, and a UserPhones table. User.id is a foreign key in UserPhones. module.exports = (sequelize, DataTypes) => { const Use

How to set auto increment primary key in PostgreSQL?

I have a table in PostgreSQL with many columns, and I want to add an auto increment primary key. I tried to create a column called id of type BIGSERIAL but pgad