SQL join table result of 2 statements

I am trying to get data with SQL from my WordPress database by a JOIN, but I do not get it working. What I need: Posts where the meta_key “gtp_product_dont_show” exists and where the meta_value not is “true”. And posts where the meta_key “gtp_product_dont_show” does not exists. My Problem: I now only get the results […]

NHibernate transactions commit failed

In production I had an episodic timeout exception during commit an Nhibernate transaction. But the records that I expect updated are correct! In stage environment nothing to report. Here below the application logs of my batch program. ERROR 2015-06-25 01:32:01,165 SRV-IIS03 Commit failed System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of […]

Customized search with special characters

I am creating a key-wording module where I want to search data using the comma separated words.And the search is categorized into comma , and minus -. Take a look on the example what I exactly want to do is I have a main table name tbl_main in SQL AS_ID KWD 1 Man,Businessman,Business,Office,confidence,arms crossed 2 […]

SQL Server Function/Proc evaluate an expression(s) return an error if not valid

I would like to take the code below and create a common function to pass in one or more expressions and to return back an error of my choosing. Example Code: IF @Variable1 IS NULL AND @Variable IS NULL or @Variable3 is not null BEGIN — EITHER DATASET NAME OR ID MUST BE SUPPLIED. SET […]

sql select from table then compare with other table in one statement

I have to tables in one database. users user_activate I have to variables in php $username = foo; $key = jas823k123ksd34324; Now I want to select from the table users the attribute user_id where user_username == $username I do this with this statement $sql = “SELECT user_id FROM users WHERE user_username = ‘$username'”; $result = […]

Adding a record with a stored procedure does not quite work

I’m experiencing some issues with adding a record in a ms sql server database with an access form. I enter data in my access form, then I execute a stored procedure which should add the data to 2 different tables. The issue here is, the data is being submitted to one table, but not in […]

Issues returning values from SQL Server table

I have an application that is supposed to take a decimal input, push into a stored procedure and return a char value for use in the application. For some reason, all of my other stored procedures seem to be working fine, however this one particular stored procedure is not working at all. Originally, the input […]

Simplifying a repetitive SQL Server query

I’ve got a repetitive SQL query to populate a simple table based on subaccounts/years, from a list of amounts held by subaccounts/years, but there is not a one to one relationship. The output is for an SSRS report. CREATE TABLE [dbo].[Results]( [SchemeDescription] [varchar](50) NULL, [SubAccountYear] [varchar](15) NULL, [RowNumber] [int] NULL, [2008] [money] NULL, [2009] [money] […]

SQL Stored Procedure with Dynamic Column Names

I am trying to generate a SQL statement that dynamically get column names from the database based on a filter. We have a table with about 50 columns with a prefix on each column to signify which “set” it applies to. I have created an Query that runs fine in SQL Management Studio, but as […]

How to copy row in table with key column

How to copy a row while in her auto-increment key column INSERT [Table] SELECT * FROM [Table] where [Table].[id]=7 not work

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