Tag: mysql

How to generate SQL Server database from schema.rb file?

I have an MS SQL Server 2012 instance with managment studio and I have schema.rb file which contains the following: # This file is auto-generated from the current state of the database. # Note that this schema.rb definition is the authoritative source for your database schema. ActiveRecord::Schema.define(:version => 20120525100324) do create_table “academic_details”, :force => true […]

Count number of entries in time interval 1 that appear in time interval 2 – SQL

I am new here and tried to look up the answer to my question but couldn’t find anything on it. I am currently learning how to work with SQL queries and am wondering how I can count the amount of unique values that appear in two time intervals? I have two columns; one is the […]

can we declare variable dynamically

Question 1: with in store procedure,can we declare variable dynamically like below: declare @i int =1; declare @s nvarchar(max) =”; while(@i<5) begin set @s = concat(‘declare @temp’,@i,’ nvarchar(max);’); exec (@s); set @i=@i + 1; end if we can declare the variable dynamically like above then what will be the scope of this kind of variable? […]

SQL query to accomplish the following this task?

I have the tables with columns as follows: Table 1 (Instance Table): Name | Id | Duration | ConfigurationID Table 2 (Class Table): Configuration | Id | Last Changed In my table 2, I have rows with Configuration names as follows. Names are code-generated.: Test 1 Copy of Test 1 Copy of Test 1 (1) […]

Openquery insert not working

I have a linked MySQL -server to MSSQL-server and I am trying to INSERT data to the table admin_user on the MySQL -server, but end up getting the error: Cannot process the object “dbo.admin_user”. The OLE DB provider “MSDASQL” for linked server “MYDB” indicates that either the object has no columns or the current user […]

Entity Framework Code First GenericTypeArguments

I have the unfortunate task to create an MVC project that uses both an MySQL and MSSQL database. To do that I use Entity Framework 6 code first and its working on both databases. The problem however is that MSSQL supports Schemas and MYSQL does not. If I add the modelBuilder.Entity<Status>().ToTable(“Status”, schemaName: “Client”); I get […]

Average of averages in multiple tables

This is the first time I use this website, so I hope I use it correctly. I am very new to using PHP and MySql, so I apologize if this is a stupid question. I want to create multiple tables that will hold data about multiple marching band performances. For instance, I have a table […]

Updating data using a SELECT query (with two related tables)

I have been trying to update the data behind a SELECT query, but not getting too far, so I have created a new database, with the hope of finding a solution. I have two tables: table_a and table_b table_a: ID, item_to_match, new_value *(this is initially blank)* table_b: IDB, item_to_match, new_value *(the value I want to […]

getting wrong result with sql sum function

select c.c_name, sum(s.net_amount) – sum(cp.recived_amount) as amount from customer_payments cp inner join customer c on c.c_id = cp.customer_id inner join sale s on s.cId = c.cId group by c.c_name having sum(cp.net_amount) – sum(recived_amount) !=0 I have 3 tables: Customer(cId)(cName) Sale(cId)(net_amount) Customer_payment(cId)(received_amount) I want to sum net_amount and received_amount and subtract them both. Through inner join […]

I need to merge data from 2 columns to another column. And then merge all rows of that added column into one cell in another table

I need to merge data from 2 columns to another column. And then merge all rows of that added column into one cell in another table.. Added two columns to one a column.!! to see image click [http://i.stack.imgur.com/srcrp.png] code used : SELECT (CustomerName + ‘ ‘ + ContactName) as onecolumn from company_PR Now I need […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.