SQL Server is a relational database management system from Microsoft. Use this tag for all SQL Server editions including Compact, Express, Azure, FastTrack and PDW.
0
votes
1answer
9 views
inserting data into a table that has a many to many relationship
I am working on an assignment and need your help with the following in SQL database:-
I have 3 tables
Product
LintItem
Invoice
LineItem is a bride table and I need to insert data into LineItem ...
0
votes
2answers
14 views
Query user logins using distinct and reprot back daily, weekly and monthly usage
I have a SQL Query, that I'm looking to report back site usage hourly, daily, weekly and monthly.
I require the query to use Distinct as the nature of the application will create several entries to ...
0
votes
1answer
31 views
How to speed up SQL Server query with grouping and filtering
I have quite common task to show history of sales in our web application (asp.net + mssql).
I have a table with sale transactions like:
- SellerID (string)
- Product PartNumber
- Product ...
0
votes
2answers
28 views
Hourly average except when hour has only one value
I have the following query which works on SQL Server 2012 to give me the hourly average of the values in the CounterValue column:
select
dateadd(hour, datediff(hour, 0, CounterDateTime), 0),
...
0
votes
2answers
22 views
Select query from XML data
I am trying to get result from XML data but only getting a value of first node.
create table #temp(xmlString nvarchar(max))
insert into #temp (xmlString) values
('<?xml version="1.0" ...
0
votes
4answers
234 views
coalesce two records into one
I have a table that stores two values; 'total' and 'owing' for each customer. Data is uploaded to the table using two files, one that brings in 'total' and the other brings in 'owing'. This means I ...
0
votes
0answers
16 views
I've backlogged queries on my SQL Server - what now? [migrated]
So, I'm a bit of a plonker right...
By accident, I issued in the region of 500,000 individual queries against my DB. It's been running for 6 hours now. I restart the server, they continue to insert. ...
0
votes
4answers
36 views
There is already an object named 'Roles' in the database
When I try to execute my TSQL code, I get the exception:
Msg 2714, Level 16, State 6, Line 2
There is already an object named 'Role' in the database.
Msg 2714, Level 16, State 6, Line 2
There is ...
0
votes
1answer
19 views
Crystal Report For Dynamic Column
I do a dynamic pivot sql query to get results like ,
ANd for that my query is given below,
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT ...
1
vote
1answer
31 views
Handling timezones
I have a view on a database that gets me the status of some work items. For example, it gets a start date, and end date, and then does some maths based on GetDate() to return me a 'Work Remaining' ...
0
votes
1answer
24 views
change the sql server server name from old to new?
Here i want to change the sqlserver server name,
Present it is HOME-878557657E\SYSTEM
i want to change this some thing like system simply, because visual studio not taking \ it the connecting string.
...
1
vote
2answers
13 views
Batchwise Script Execution
I have long script which contains the Create tables, create schemas,insert data,update tables etc.I have to do this by only on script in batch wise.I ran it before but it created every time some error ...
0
votes
3answers
33 views
minimizing function calls inside dynamic sql?
How do I get rid of the multiple convert functions in the following dynamic SQL?
IF @MediaTypeID > 0 or @MediaGroupID > 0
BEGIN
SET @SQL = @SQL + 'INNER JOIN (SELECT lmc.ID FROM ...
0
votes
0answers
22 views
Attach Database using Management studio points to the wrong file path for the log file
I am trying to attach a SQL server 2000 MDF and LDF which were created on a different machine and attach them to a SQL Server 2008 R2 on different machine. The SQL server files at the original ...
0
votes
1answer
23 views
How to edit schema of SQL Server CE table
The case / scenario is :
I have already created the table in SQL Server CE with no data entered yet.
I have an 'Id' field with primary key.
Now, when i try to edit the schema to make 'Id' ...