Tagged Questions
Microsoft SQL Server is a relational database management system. Use this tag for all SQL Server editions including Compact, Express, Azure, Fast-track and PDW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, etc.).
0
votes
0answers
6 views
SQL Server update statement with join
I have data in a load table and am trying to write an update statement to populate an additional self-referencing table, but am having difficulty with the exact syntax.
Here is a simplified example ...
0
votes
0answers
5 views
Dapper: Procedure or function has too many arguments specified
While using Dapper to call a stored procedure, I'm receiving the following error:
Procedure or function has too many arguments specified
I'm using DynamicParameters to add a list of simple ...
0
votes
2answers
23 views
SQL: How to add calculated column with the text being different than the value
I have a column in a table which contains a path to a file in my db. I want to display this column in my asp.net web application, but I don't want to display the path in the GridView, I want the ...
1
vote
0answers
14 views
Querying multiple MS SQL database instances on the same machine
I am new to MS SQL and I am trying to do something that seems simple but is driving me crazy.
I want to write a query to pull data from two databases. Each database is on a different instance on the ...
0
votes
0answers
19 views
How to perform string manipulations on a column with a temporary procedure?
I have this procedure :
CREATE PROC dbo.##HTMLtoMARKDOWN @text nvarchar(500),
@returnText nvarchar(500) output
AS
BEGIN
DECLARE @counter tinyint
SET ...
0
votes
1answer
19 views
Getting a count while accounting for an attribute
I have two tables, one for account information and one for customer information. An account can have multiple customers associated with it. What I want to do is grab all active customers in a given ...
0
votes
0answers
8 views
Adding and multiplying tables' data by values in another table
Say I have a table of subtractions and divisions sorted by date:
tblFactors
dt sub divide
2014-07-01 1 1
2014-06-01 0 5
2014-05-01 2 1
2014-05-01 0 3
...
1
vote
5answers
26 views
SQL Server Sum rows with string value
I have a dynamic SQL query which returns rows like below with string values & numeric values.
EMP col1 col2 col3 col4 col5
----------------------------
A1 4 4 3 3 3
A2 4 2 5 ...
0
votes
0answers
4 views
Determine field's bytes in Redshift
I am moving a table from SQL Server to Redshift. I've exported the data and gotten it into a UTF-8 text file. When trying to load to Redshift, the COPY command fails, complaining the data exceeds ...
0
votes
2answers
21 views
SQL Server : Insert Image Into Table Dynamically
I have a SQL Server table Products and I want to insert an image for each in the image column based on the product Code where the name of the image is identical to the product Code.
UPDATE Products
...
-1
votes
1answer
42 views
How to delete rows from 3 tables based on a specific value in one table
Helo Folks,
I have 3 tables. A,B,C.
I have in Table A rows whose column'date' has value '2000-1-1'.
I like to delete rows from 3 tables based on where A.date = '2000-1-1'.
Considering a join on ...
0
votes
2answers
15 views
how to retrieve data from 3 tables by checking if one public column value is present in a result list
I have 5 tables:
Users, countries ,Houses, Cars and Computers.
User table has the following columns:
- Id
- Name
- CountryId
Houses table has the following columns:
- Id
- UserId
- ...
0
votes
0answers
13 views
Microsoft Access Query Find Unmatched Query Wizard
I have an access query used from "Find Unmatched Query Wizard". Table FM31.Credits contains three rows with $300.00 and REO1.Amount contains one row of $300.00. I need the query to return the two ...
0
votes
0answers
8 views
Check_clause returns null with php_mssql
How to get the CHECK_CLAUSE (from INFORMATION_SCHEMA.CHECK_CONSTRAINTS) using php_mssql?
SELECT TABLE_NAME,
COLUMN_NAME,
CONVERT(VARCHAR(MAX), CHECK_CLAUSE) as ...
0
votes
0answers
17 views
Query works with hardcode, variables don't return correct response/general efficiency in statement
first questions on SO.
I'm getting back into SQL and having some issues with this current task. I have a large structured DB that uses a singular id with multiple lookup tables, so coreid = nameid = ...
-2
votes
1answer
41 views
how to convert this code to t-sql
i have this linq code in C#, and this working. but i want use this in stored procedure in sql server 2008. so, i want convert this to t-sql query.
var listComment = (from c in Conn.Comments.Where(cm ...
0
votes
2answers
24 views
Exchange Rate Return
I am building a Monthly License Report for our IT department and it receives a list of License information in Euro's. I have an XML feed that provides Exchange rate data daily but the job will only be ...
1
vote
1answer
25 views
SQL Server renames tables
I'm using a SQL Server from my hosting provider and the strangest things happen. The server sometimes renames my tables, to the english word - from swedish, and then uses that table instead of the one ...
0
votes
1answer
11 views
Trying to get a single record involving MAX(Date) and GROUP
I am trying to create a query in which I start with an item number and a customer and I have to determine the last selling price.
The tables involved are
SOP30200 = Sales Header
SOP30300 = Sales ...
0
votes
1answer
22 views
SQL Trigger Inserting from Multiple tables
I am trying to execute a query within a SQL trigger.
I have 4 tables A, B, C, D. Table A is a lookup list and contains roughly 1400 rows of data. Table B are values being input through an HMI with a ...
0
votes
1answer
11 views
connection error with SQL Server by double clicking .JAR file
I have a strange problem with my jar file. If I run it through cmd with
java -jar myjar.jar everything works fine and the application connects succesfully to my SQL Server database, but if I run ...
0
votes
0answers
6 views
Sql Server Modifying Users across environments
Is is possible to create a script in SQL Server that we can run after moving a database to a different environment, that will update all the users?
For example, on the database in PROD I have a user ...
0
votes
2answers
18 views
Issue with Stored Procedure modify in SQL
Trying to amend a stored procedure and getting this error
Msg 156, Level 15, State 1, Procedure webopius_OrderExport, Line 14
Incorrect syntax near the keyword 'left’.
The code is
ALTER proc ...
0
votes
2answers
28 views
Variable name as Column in Sql Server 2012 WHERE Clause
I've tried a variety of methods, and this is one I was sure would work -- but the alter storedprocedure fails at the CASE line.
WHERE v.State_combined != ''
CASE WHEN @component = ...
0
votes
3answers
53 views
Converting a C# Method to Stored Procedure
I am using SQL Server to manage my data for a website. I just decided to add two new columns to the database and I want to populate these two columns for every row in the table. To populate each of ...
0
votes
0answers
14 views
sqlsrv_num_rows() returning -1 instead of number of records
I'm using PHP 5.3 and Microsft's MSSQL driver to access MSSQL 2012.
There's this huge query, with some CTEs. It works on SSMS and returns rows. But when I use the same query on PHP, as
$resultSet = ...
0
votes
0answers
15 views
Performance Impovement after Server Restart on Microsoft Windows server 2008R2 [on hold]
We have some Microsoft Windows server used for BI processes.
Recently we have observed that the server performance degrades with time. Thought the server are not yet patched (as they are new-around 2 ...
0
votes
0answers
15 views
Using checkboxes to return result to SQL Server
I have the following code in ASP Classic:
<%
dim prac_id
prac_id = Request.Form("Practice_ID")
dim surname_id
surname_id = Request.Form("clientsurname")
If prac_id <> "" And ...
0
votes
0answers
7 views
Conflict when mapping stored procedures inside my staging and live Databases, when the SP have the same name
I am working on two databases one that is used for staging (test data) and the other is live database.
Now I created a SP on the staging server as follow:-
USE [StagingDB]
GO
SET ANSI_NULLS ON
GO
SET ...
0
votes
1answer
15 views
How to get specific XML namespace in XQuery in SQL Server
I have a XML that I need one specific namespace according to node like temprature with hls i need namespace of that "http://www.schema.hls.com/extension" I have tried with these
DECLARE ...
0
votes
4answers
38 views
SQL Server 2012 Date Change
I am attempting to convert the DATETIME Column titled CREAT_DTTM to a simple "1/1/2014" format.
I have looked at CAST, CONVERT and FORMAT functions but i just can't get it to work.
Any guidance ...
0
votes
1answer
24 views
How to query databases to get user roles?
I have been assigned a task in which I have no knowledge or experience. I am working on a .NET solution where I need to use SQL to query an instance of a database in sql. For each database in the ...
2
votes
1answer
41 views
How to get Image data from SQL Server, Write To File, Save File to Disk using C#
I'm trying to get attachments (images, word documents, etc.) stored as an Image datatype from a SQL Server database. The attachments can be of any file type, but I'm just trying to get a .jpg to ...
1
vote
1answer
20 views
Handling data truncation in Talend
I am copying data from Excel sheet to the SQL server tables.
In some of the sheets I have data bigger in size of the Table's schema in SQL.
i.e. Table's column has data type nvarchar(50) where as my ...
0
votes
1answer
26 views
SQL Server Management Studio when creating check constraints
I use SSMS and want to create a check constraint for a table.
So I right click on constraint node and select New constraint, and I set the expression to Mycolumn > 5
Then I click on close.
After ...
0
votes
0answers
8 views
SSAS MDX not returning data
I have one cube 'Performance Measure' and querying data from the cube. My problem is, on my dimensional and fact tables I can see data for July 2014, when I run a SQL query against my database then I ...
0
votes
2answers
21 views
Maintaining consistency when doing logical delete
I'm performing logical delete when an item should be deleted from the database.
I have added an additional DateTime column to every table that we need to perform logical delete. So when deleting you ...
0
votes
0answers
15 views
“net start” - System error 1067
How can I fix system error 1067 which is the error I get while starting a service using the net start command in Windows 2003 Server?
C:\..>net start "<Service Name>" arg1 arg2
<Service ...
0
votes
1answer
31 views
Subtracting Time (Hours) By Next Day
I'm having a bit of an issue where trying to subtract (using DATEDIFF) two times from one another and produce a total amount of hours. This isn't an issue mostly however, sometimes the subtracted ...
0
votes
4answers
47 views
sql join including null and non existing records
I have the following tables. I am trying to get a join of these 4 tables where it will list all the questions, even if the user didn't answer anything along with user and category.
any help?
select * ...
0
votes
1answer
18 views
creating a password field in SQL SERVER 2008
i have to create a password field for my Diver table,
the password has to be exactly 8 characters, and only numbers (0-9) and letters (a-z) are
allowed. how do i do that?
i tried:
create table ...
0
votes
3answers
35 views
Using max and other SQL aggregate functions
Whenever I use SQL aggregate functions I find their utility hampered by the need for the Group By clause. I always end up having to use a bunch of nested selects to get what I want. I'm wondering if ...
0
votes
1answer
24 views
SQL UPDATE with JOIN for WHERE Clause
Hopefully an easy question: I have two sql tables Items and BillOfMaterials
Items has fields ItemID and ItemCategory
BillOfMaterials has fields ItemID and ComponentItemID
How can I do an UPDATE on ...
0
votes
0answers
12 views
SQL Query to determine when ticket in jira changes status
I am trying to write a sql statement that will query Jira (6.1), and for each issue, will list when the workflow status was altered. Currently i do not need to know who altered the workflow, just the ...
1
vote
4answers
36 views
use IF…THEN Sql query and return int and String
I have this Table
CREATE TABLE [dbo].[Room] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Name] NVARCHAR (32) NOT NULL,
[Capacity] TINYINT NOT NULL,
...
-1
votes
0answers
42 views
I need to calculate values for a record in a database based off of other values in other records
I need to calculate values for a record in a database based off of other values in other records. Using SqlServer 2012, what would be the best way to do this? I'm thinking some type of script that ...
1
vote
1answer
26 views
Remove portion of string TSQL
I have a string of numbers that I need to trim a portion from using TSQL.
The string of numbers will always start with a 101 then it will have a set of 0's and a set of random numbers.
Example: ...
0
votes
0answers
19 views
Calculating a % rate based on two date dimension in one cube
Set up - SSAS 2012 with OLAP cubes (built by supplier) and MS Report Builder v3. No access to BIDS.
I am building a report which needs to calculate a disposal rate based on data from a single cube. ...
0
votes
0answers
5 views
IIS 7/MSSQL Server debugging
I am developing a WCF service, so far I have added only a few simple interfaces. Testing the service in the VS debug environment, all is well.
When I published the service to IIS 7 for further ...
0
votes
0answers
21 views
sql server 2008 merge and delete [duplicate]
I have a table and I want to upsert (insert +update) it to another table.
This is my stored procedure
ALTER PROCEDURE dbo.sync_merge_delete
AS
BEGIN
SET NOCOUNT ON;
merge into FRM_DTA as ...