When we copy a database down from production, we make a backup of the database, zip it up and copy the backup down. Then we have to restore using the SQL Server GUI, which involves navigating through several menus and windows. As far as I know, you can not do this with SQL Server's built in stored procedures because you may not know the ...
Hi All,
I'm looking for a good way to maintain permissions on who can add data to a database in a C# app and SQL Server 2005.
I need to explain though to make this clear. So let's take an example of this:
I have two users Bob and Jim, both have been added to the SQL permissions so they have write access to the database. Now all access...
Ok, so I am not even sure where to begin here. SQL programming is fairly new to myself.
Also before I go on about my issue I would like to be able to complete this in LINQ and not using stored procedures.
Problem: I have multiple nested classes and I need to be able to add the classes to several tables in a sql database. I need to also...
Hi,
Can anyone suggest how to debug stored procedure from a remote sql server using visual studio.net 2005?
I am able to debug my stored procedure from local server, but I'm unable to do so if the sql server is remote. I will often get an error that
"Unable to start T-SQL Debugging.Could not attach to SQL Server process on [Remote S...
I have two instances of SQL Server 2005 running on two separate dedicated servers (let's call them DB1 and DB2). At the moment DB1 is very busy and DB2 is mostly idle. Is it possible to configure the instance running on DB1 to utilize the processor on DB2?
For example, I connect to DB1 and execute "sp-heavy-going" and I would like DB1 ...
I have lots of data with start and stop times for a given ID and I need to flatten all intersecting and adjacent timespans into one combined timespan. The sample data posted below is all for the same ID so I didn't list it.
To make things a bit clearer, take a look at the sample data for 03.06.2009:
The following timespans are overlap...
I need help with a query?
I have 2 tables reservations & units among others.
Table reservations has columns ResId,rfrom(datetime),rto(datetime),status(int),UnitID(foreign key).
Status 2 means its confirmed.
I need to get all free units in requested period, query needs to return only that units for which there aren't confirmed reservatio...
I have a WPF application deployed via ClickOnce. This application uses a SQL Server Express database. I am trying to access my user instance of the database so that I can access the database that I am currently using when debugging so that I can verify writes to the DB made by entity framework. However, when I try to open the user instan...
Hi,
I am scheduling the a query to a table for each database in a particular instance. The query and table for each database are similar. I direct the query results to text file. Before the query results, I include the database where the particular query is being made. In my test in AdventureWorks, however, the result I got is a databas...
How can i resolve a hostname in t-sql? a 2000 compatible method is preferred. Although something that works on 2005/2008 would also be helpful.
eg. If i have the hostname stackoverflow.com i want to return 69.59.196.211
...
what will be the effect if uniqueidentifier data type column is clustered/Non Clustered index in a table sql server 2005/2008. I read it is badly designed table, how to avoidy this problem and what is the best solution?
...
select HASHBYTES('sha','what is it')
Result --0x2327A09C2FDAD132E436B5CC12E9D5D283B5BA69
is it possible to convert back hashbytes to string '0x2327A09C2FDAD132E436B5CC12E9D5D283B5BA69' as a input
want to get out put as 'what is it'?
...
Hello,
How to export a database schema and the data in Microsoft SQL Server Management Express? In other words given a database and the data, I want to create an .sql script that will recreate the table structure and the data inside it.
...
I would like to write a 'generic' script to operate on a number of databases. The 'use databasename' commands will be distributed in the body of the script. I would rather show the database name information at the top of the script. So ideally:
declare @db varchar(100)
set @db = 'data_in'
use @db
This fails. So perhaps
declare @db ...
This query returns me first below table. forexample; 2009-06-01 00:00:00 people enter my system '41' times. i need second table
declare @date1 smalldatetime, @date2 smalldatetime , @countgap int, @page nvarchar(100)
select @date1='2009-01-01', @date2='2009-12-30 23:59:59' ,@countgap=1, @page='Tüm Sayfalar'
declare @@date1 smalldate...
Hi,
im trying to realize something like this:
DECLARE @id int
declare @cont varchar(max)
declare @temp varchar(max)
DECLARE curs CURSOR FOR SELECT id, [content] FROM [dbo].[Contents]
OPEN curs
FETCH NEXT FROM curs into @id, @cont
WHILE @@FETCH_STATUS = 0
BEGIN
SET @temp = replace(@cont, @param_ReplaceThis, @param_WithReplace...
Is there a quick and easy way to list when every index in the database last had their statistics updated? The preferred answer would be a query. Also, is it possible to determine the "quality" of the statistics: FULLSCAN, SAMPLE n, etc.
EDIT
this worked for what I needed, a slight mod to @OrbMan great answer...
SELECT
STATS_DATE(...
Here is the problem I am trying to solve. I have a table where I store a StartExclusionDate and EndExclusionDate and set an ApplyDate for my object (called Exclusion). There can be many ExtId entries in the table.
I want to get the ApplyDate from the last continuous record where a date passed to the query is included between the Start...
I have a Master File table on a server(A). Data is first replicated to a central server(B) and then to all of our locations(C). Then from C->B->A
A = Sql 2005
B = SQL 2005
C = Sql 2000
My issue is that data gets all the way to C but replication is set for updates yet I get a Primary Constraint error from C -> B. I set loopback detect...
I have a large DB table which I am using for testing. It contains 7.3m phone call records. I would like to delete many of those, but still maintain a good spread over phone numbers and dates. Is there any way of achieving this? Maybe something to do with table sample?
...