I have table like this From this I need to create a temp table or table like this: Is there a way I can do this in SQL Server? Answer Check this Fiddle If you do want NULL values in the rest, you may try the following: This is the new Fiddle And here is the code:
SSIS: generate create table DDL programmatically
Is there source or library somewhere that would help me generate DDL on the fly? I have a few hundred remote databases that I need to copy to the local server. Upgrade procedure in the field is to …
Membership stored procedure aspnet_Membership_CreateUser not working
I have been trying to make the build in stored procedure to work with Register.aspx. I’m not using the wizard part. Hence writing my own code. I don’t understand where the error is. If I use exec stored procedure and send the same value it will execute in Management Studio. But in code it fails. H…
How to run OPTIMIZE TABLE with the least downtime
I have a MySQL 5.5 DB of +-40GB on a 64GB RAM machine in a production environment. All tables are InnoDB. There is also a slave running as a backup. One table – the most important one – grew to 150M rows, inserting and deleting became slow. To speed up inserting and deleting I deleted half of the …
Complicated MySQL Select query
Here is my table layout: What I would like to do: Count the number of votes for each songID in a particular room (passed in as a parameter). Find out if the userID has at least one vote for a song in a particular room. UserID is also passed in as a parameter. An extension of the two above. If
Query to check if date is between two month-day values
I want to know if a date (Year-Month-Day) is between a day of the month (Month-Day). For example, I want to know if ‘April 2, 2013’ is between ‘April 2’ and ‘April 19’. I can easily do this of the range has a year value. Howver, without a year, I need ideas how to do this. …
Why can’t I use SELECT … FOR UPDATE with aggregate functions?
I have an application where I find a sum() of a database column for a set of records and later use that sum in a separate query, similar to the following (made up tables, but the idea is the same): …
ERROR 1148: The used command is not allowed with this MySQL version
I am trying to load data into mysql database using the topic of this question is the response I get. I understand the local data offloading is off by default and I have to enable it using a the command local-infile=1 but I do not know where to place this command. Answer You can specify that as an additional o…
How to visualize database tables in postgresql using pgAdmin?
I am trying to visualize tables and their relations using pgAdmin. I have understood that there is a query visualizer tool available for pgAdmin. However, that only is useful if you are dealing with queries. My main goal is to generate a graphical representation of all the tables available in database. Answer…
meta_query, how to search using both relation OR & AND?
Resolved: See answer below. I have a custom post type called BOOKS. It has several custom fields, named: TITLE, AUTHOR, GENRE, RATING. How do I fix my meta_query code below so that only books that have the search word in the custom fields: title, author, genre WITH EXACTLY the rating specified in my search fo…