This tag is specifically for the 2008 version of Microsoft SQL Server.
1
vote
1answer
73 views
table design to track significant events associated with an item
An Orders table I'm dealing with at present in design phase has about 10 or more columns.
Each OrderID in the Orders table will have certain significant events or milestones. The number of Orders ...
3
votes
1answer
179 views
Schema design: Use of association (aka: bridge/junction) table vs foreign key constraint with composite index containing a non-key field
This is an inventory database for IT assets. The models used are trimmed in order to focus on the problem at hand. Using SQL Server 2008. Thanks for taking the time to read and for any input you can ...
0
votes
4answers
114 views
Update Table A row if Table B row is changed
Is is anyhow possible to tell the database to execute a little script, if a row is changed in a table?
Scenario:
The database constantly monitoring Table B to see if rows are inserted, updated or ...
1
vote
1answer
219 views
Creating indexes with t-sql scrips vs rebuild indexes in maintenance plan
I’m using SQL Server 2008 and I am running several (15) scripts each day to bulk insert to tables. Each script drops the table at the beginning. I create indexes in the scripts. Some of the scripts ...
1
vote
0answers
98 views
Why would running DBCC FREEPROCCACHE result in different data being returned? [closed]
I experienced a situation where a query run directly in SSMS was giving a different result set than the same query run from code on a web server, using the same database.
After spending a lot of time ...
2
votes
0answers
148 views
Why do I get “The initial snapshot for publication is not yet available.”?
We are using Transactional Replications with updatable subscriptions. 1 publisher, 1 subscriber.
SQL Replication started encountering a constraint error on 3/6 at 10AM because people at two different ...
1
vote
2answers
98 views
Does this query make sense?
I recently migrated a database from Sybase ASE to Microsoft SQL 2008r2.
One category of queries that was broken in transit is:
SELECT person_id
FROM leaveperiods
WHERE group_id=146
GROUP BY ...
1
vote
2answers
123 views
How to find DELETE and UPDATE statements that have been executed on a database?
I am trying to find out what delete and update statements have been executed on a certain database in a certain period of time.
I came across this following query, but it generates an error message:
...
0
votes
1answer
68 views
What is the maximum number of rows in a clustered index on datetime column?
I would like know what the max no of rows is in a clustered index (non-unique) on a datetime column table in SQL Server 2008R2.
1
vote
1answer
185 views
TSQL DateTime DataType - fractional seconds vs milliseconds
Wanting to get all records from a single day. So everything between 2013-03-05 00:00:00.000 and 2013-03-05 23:59:59.999. We're getting overlap at the backend with things that happened at 2013-03-06 ...
2
votes
0answers
120 views
SQL Server Database Hot Backups: Which Technique(s) to Use for Multi-Level Replication?
I'm reading the many other posts here about mirroring vs. replication, but I'd still appreciate it if someone with some experience would weigh in.
My small development team needs to have local ...
2
votes
2answers
320 views
Check if row exists
I need to write a query that will insert a row only once, even if the query is run multiple times. Being new to SQL (well new-ish), I did an if not exists(...) but a friend said he preferred deleting ...
0
votes
3answers
125 views
Select MaxDate where hh:mm:ss makes the difference
How to select the maximum date from a table where hh:mm:ss is selected?
My query is the following, and returns the latest date, but if there are different times recorded, the date will be returned ...
0
votes
2answers
96 views
Error while connecting SQL Server management studio 2008
I have installed SQL Server 2008 management studio. When I connect, it shows an error. Also when I go to the SQL Server configuration manager and click on SQL Server SERVER services, this message is ...
1
vote
1answer
93 views
What does the bit data type map to in a Java Domain Object
When you have a column of the bit data type what Class would be used to represent that in a Java POJO mapping that table to an object which is using javax.persistence annotations?
I tried Boolean, ...
4
votes
1answer
140 views
Join To a @Table Variable is running ineficiently
Alright so I have a report sproc that was running incredibly slow. Customers were complaining that the report would not run so I started investigating exactly where in the sproc the problem was and I ...
0
votes
2answers
67 views
Need a way to query a table, and JOIN it with the TOP 1 related record from an other table
As a follow up to this question, I'm wondering if there is a better and/or more efficient way to gather the data in question.
As stated, this query does return me 95% of the data I need --
SELECT ...
0
votes
3answers
100 views
Fixing a query that returns failed job information
I' using a SQL Server 2008 Sp3 environment.
I have a query that returns information about failed jobs from the last 10 minutes.
If a job has two schedulers (for example - a job that runs every 10 ...
1
vote
2answers
213 views
Change Data Capture and the __$update_mask binary
We're using CDC to capture changes made to a production table. The changed rows are being exported out to a data warehouse (informatica). I know that the __$update_mask column stores what columns ...
2
votes
2answers
80 views
Why do I need to use a sub query to filter down a grouped select?
If I do this --
SELECT dv.Name
,MAX(hb.[DateEntered]) as DE
FROM
[Devices] as dv
INNER JOIN
[Heartbeats] as hb ON hb.DeviceID = dv.ID
WHERE DE < '2013-03-04'
GROUP BY dv.Name
...
4
votes
1answer
38 views
Can I query data_space names when not in context of the database for multiple databases?
I have a data set pulled from sys.master_files. The data set looks something like this:
database_id filename physical_name data_space_id
----------- ---------------- ------------- ...
0
votes
1answer
119 views
SQL Server primary key create clustered index
I've inherited a database where no primary keys were defined on the tables. There are also no clustered indexes assigned to the tables.
If I perform an alter table to assign a primary key will this ...
2
votes
1answer
406 views
How to succesfully run a batch file in an SQL Agent job?
I have a SQL Agent Job which generates a specific report in PDF-file and then copies the PDF to a network directory and then deletes the PDF file in the source directory.
The SQL Jobs consists of 2 ...
2
votes
2answers
108 views
SQL Server media belongs to which edition
Could anyone please help me on below question?
Without installing SQL Server media 2008 and 2012, how can we know that the media belongs to which edition (like developer, standard or ...
1
vote
0answers
374 views
The Cluster service failed to bring clustered service or application 'SQL Server (MSSQLSERVER)' completely online or offline
SQL Server service restarted/stopped, which cause the production database down n find this errors in System log.
ERROR5:The Cluster service failed to bring clustered service or
application 'SQL ...
3
votes
1answer
74 views
Compressions vs shrinking a database
Is compression and shrinking a database in SQL Server same? If I compress a table, will it decrease query performance and DML?
2
votes
1answer
208 views
SSIS 2008 Package Configurations being ignored
With the change to package configurations in 2008 compared to 2005 when I specify /ConfigFile something.dtsConfig on the command line, variables defined in the package are keeping their design-time ...
0
votes
3answers
166 views
What is ERROR_STATE() in SQL Server and how it can be used?
I read that ERROR_STATE() can help to distinguish between different states/locations in the source code where same type of error can occur. But it is not really clear to me that how it can be useful.
...
1
vote
2answers
83 views
Pull Access schema into a SQL Server table
We had an assembly that used to pull a list of tables and their columns from an Access database and place the listing into a SQL Server table for later use. For various reasons the assembly is no ...
0
votes
0answers
50 views
How can a SQL database be migrated to MySQL faster?
I have a SQL Server DB. I want to migrate that DB to MySQL. In my SQL Server DB, some tables has about 50,000 to 1,00,000 records. I am trying to migrate the DB by DB migration tool embedded in MySQL ...
5
votes
3answers
205 views
Create procedure in else block on SQL Server
I have a SQL script in which I generate a database and its tables, stored procedures, views, etc. I have used following script to generate the database and all the things.
I was able to generate ...
2
votes
1answer
197 views
Select the top 5 records and the specific column from each table in the same database
I have 50+ tables in a database.
I don't want to use the following SQL on each table in a database.
select top 10 * from {table_name}
So, is it possible to display the first 10 records PLUS only ...
0
votes
3answers
211 views
How to select the first 10 records for each table in the same database using sql
I have 50+ tables in a database.
I don't want to use the following SQL on each table in a database.
select * from {table_name}
So, is it possible to display the first 10 records for each table ...
2
votes
2answers
64 views
How to check for mutiple rows with same data?
Hi all can anyone advise how do i check mutiple rows with same data?
E.g.
I have 2 rows with following values:
Cola Colb Colc
TYPE_APPLE 123 abc
Colb Colb Colc
TYPE_APPLE ...
1
vote
0answers
62 views
Does disabling index exists in a table? [closed]
So I have a script that runs daily. It creates a temp table then inserts the records to a table from the temp table. The script used to create indexes but few months ago I commented out the index ...
2
votes
2answers
115 views
Reseed a newly created table
I have create a new table on SQL Server 2008.
This table has an identity column, defined like this:
[ID] [int] IDENTITY(1,1) NOT NULL
However when I insert any data, the first record starts from ...
0
votes
2answers
92 views
Output count percentage in 2 decimal places
I have the following sql query code and I can not get to execute the desired output.
SELECT Deal_type, Price_type,
cast(sum(Deal_type)/count(Deal_type)*1.0 as decimal(12,2)) as results
FROM ...
2
votes
2answers
174 views
How to refresh AD security group on Sql Server permissions
I am using Sql Server 2008 on Small Business Server 2003; client is using WinXP.
I added a user to my Active Directory Security Group; Why can't this user immediately access the database? It seems ...
2
votes
0answers
49 views
Stored Procedure Performance Issue
I have a stored procedure that is stalling the database. If the stored procedure is run as a query, the results arrive nearly instantly. If the stored procedure is run as a stored procedure, with it's ...
2
votes
1answer
79 views
How to solve index missing problem in one table, while other table of same property does not produce any error?
Two databases with same structure at least for my eye. One of them was used as training/testing, where I can add list of products in Art table via a program's extension FDT but not in Art table of ...
1
vote
0answers
250 views
database 'msdb' cannot be opened. it has been marked suspect by recovery 2008 error code 926
I m using SQL server 2008, i got suddenly today an error while i was accessing database from visual studio the error is database 'msdb' cannot be opened. it has been marked suspect by recovery 2008 ...
1
vote
1answer
164 views
Add Check Constraint On Varchar Column to enforce no duplicates
I have a varchar(max) column where users will populate a pre-given key from another system. I want to enable that the users are forced to enter a unique key which means no duplicate values on that ...
9
votes
2answers
268 views
Is data retrieved from SQL Server compressed for transmission?
Is data retrieved from Microsoft SQL Server compressed? If this is controlled by the connection string, is there any simple way to tell if any particular app is using it?
I'm examining analysis ...
4
votes
1answer
118 views
Transaction Log maintenance on Mirror database
SQL Server Version: 2008 R2 Enterprise SP2
I am trying to get a handle on our SQL Server maintenance and I came across something I think is incorrect. We have a single production instance with 3 ...
1
vote
1answer
118 views
“The SELECT permission was denied” only for some of my tables
In my database there are about 100 tables on 2 tables I get the following error when accessing the database by a SP (all data access uses SP):
The SELECT permission was denied on the object 'XXX' ...
2
votes
4answers
391 views
Manually set log file size after shrink SQL Server 2008 R2
Am becoming a somewhat involuntary DBA at work at teh moment and really need some help on something.
We have a 40GB database in Full Recovery Mode, no log backup configured and a huge log file of ...
2
votes
2answers
210 views
Automatically restart SQL Server 2008
Is there a "best" way to automatically restart SQL Server on a regular basis? I read that I could create a batch file to net start, net stop the agent and service in a batch file and schedule that, ...
0
votes
0answers
20 views
Twice job results in sql server, last one is left in progress [duplicate]
I have the job MP - Create CSV which execute a package SSIS in sql server 2008, when I check for the job history I see the result at step 0, I expand and I have 2 results for the step 1.
Fist result ...
3
votes
1answer
55 views
Analysis service database security at application level
I have got a SSAS Cube, we have written an windows application which would issue MDX queries to access the data from the cube and show it in the reports .
This windows application is a licensed ...
2
votes
1answer
80 views
Twice job results in sql server, last one is left in progress
I have the job MP - Create CSV which execute a package SSIS in sql server 2008, when I check for the job history I see the result at step 0, I expand and I have 2 results for the step 1.
Fist result ...
