sql-server

How to transfer SQL Server DB structure to another server

Tell me please what's the best way to copy db structure to another server? I'm trying to generate a script in Management Studio and then run that script on the remote machine. And I hate that thing. It works unpredictable, you have to fix manually a lot of crap in the generated script. I guess that isn't the best solution. Then I tried...

List number of rows per field value in SQL

Hi, database/SQL novice here. I have a table with a column called, for example, "EmployeeID". I want a query that will, for each distinct employeeID, return the number of rows that have that as their ID. I hope it's clear what I'm trying to do and someone will know how to help! I don't think it should matter, but just in case, I'm usin...

What is a "schema provider" in an RDBMS?

Could someone please define what is meant by a schema provider? I'm familiar with DB schema (in this context, I take them to mean a named, logical container for DB objects). Why would a schema provider be useful? From a high level, how do they operate? The context here is SQL Server 2008. ...

SQL Server - How to Grant Read Access to ALL databases to a Login?

I need to give a new login read access to all 300 databases on a server. How can I accomplish this without checking 300 checkboxes in the user mapping area? ...

SQL Server query to create database is giving me an error when I include numeric characters in the database name

I am having trouble running a simple sql query in Microsoft SQL Server 2005 to create a database and im not sure why. When I run this query CREATE DATABASE 4444-virtual2 I receive this error Incorrect syntax near '4444'. Is there anything in particular that I must specify if I am creating a database table with numeric values in...

ssis - flat file source - The process cannot access the file because it is being used by another process.

Am attempting to use SSIS flat file source to read a log file being actively written to. Looping and waiting for the file to be released is not practical as this is an active log file held by a service. Ideally, I'm looking for a setting upon the flat file source, similar to the C# code below. If not that, what route can I take to rea...

SQL query that applies aggregate function over another aggregate function

I have several query results that use one or more aggregate functions and a date GROUP-BY so they look something like this: Date VisitCount(COUNT) TotalBilling(SUM) 1/1/10 234 15765.21 1/2/10 321 23146.27 1/3/10 289 19436.51 The simplified SQL for the above is: SELECT ...

How to find all foreign keys?

I'd like to find all referencing tables in my db that have a foreign key that points to a specific referenced table. Is there a query that I can run to do this? Not sure if the question is confusing. Let me know if it is and I can try to explain it in more detail. ...

How do I customize the Membership database tables created by ASP.NET ?

Hello, I want to add custom columns to some tables created by ASP.NET. For example; I need to add two fields such as FirstName and LastName to the aspnet_Membership table. I can add this directly by editing the table but; Is this the right thing to do (I mean; extending the table directly) OR should I create a separate table and ho...

Include a blank row in query results

Is there a way to include a blank row at the top of a sql query, eg if it is meant for a dropdown list? (MS Sql Server 2005 or 2008) Select * FROM datStatus ORDER BY statusName Where I want something like -1 (please choose one) 1 Beginning 2 Middle 3 Ending 4 Canceled From a table that is ordinarily just the...

SQL Server Database - Allowing application to edit records in a view?

I made a custom view for a group of three tables. How would I configure the view so that it can be edited by an application using it like a table? I am using SQL Server Studio Express. ...

GROUPING DATEs in sql

i have a table in which there are ids and resigning dates. a singlle id have more than one resigning date. how can i display the table in which one id have only one resigning date which is the latest ie the maximum date. can somebody help me plzz....thanx a ton ...

Asynchronous Sql Execution in .NET

In my Program I'm calling a Stored Procedure through asynchronous call connection.Open(); IAsyncResult ar = cmd.BeginExecuteReader(); While executing the Page, If I click back button Page will be redirected to other page but the front-end objects cannot handle the back-end processing. How can I stop running the Stored procedure? ...

Are execution plan for functions cached in SQL server?

Hello All: Can any body help me in understanding if the execution plan for functions cached in SQL server? Any online resource for this? Thanks Ashwani ...

ALTER TABLE DROP COLUMN FAILED

I'm trying to clean up a database table and I'd really like to drop two columns as they should no longer be being used. 'Property' table - Unable to modify table. The index '_dta_index_Property_7_669245439__K1_K9_K8_K24_K4_2_5_6_13_22_25_26_29' is dependent on column 'AveragePriceMta'. The index '_dta_index_Property_7_669245439__K1_K9...

Microsoft Sync Framework between Sql Server(Client) to SQl Server (Server) with change tracking possible?

I want to realize an offline scenario where client and server are SQL Server databases. Preferably with SQL Server Change Tracking. Is that possible and a reasonable option at all? From trying out it seems to me the only sql server to sql server sync is in collaboration mode and doesn't leverage sql server change tracking. (SqlSyncProv...

TSQL: Exact match with a SP using a LIKE?

Hello, I've a SP using a LIKE. Let's simplify it to: SELECT * FROM customers WHERE name LIKE '%' + @query + '%'. I'd like to use it for an (optional) exact match search without altering the SP but with a tricky parameter ;) Is there a way to "cancel" the 2 '%' with a clever @query? Thanks. ...

How can i solve "Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong." ?

If I try to execute below query: EXEC sp_rename 'ENG_TEst.[ENG_Test_A/C_TYPE]', 'ENG_Test_AC_TYPE', 'COLUMN' I get an error: Either the parameter@objname is ambiguous or the claimed @objtype (COLUMN) is wrong. How can I solve it? ...

Is it possible to set a timeout for an SQL query on Microsoft SQL server?

I've got a scenario when sometimes a user selects the right parameters and makes a query which takes several minutes or more to execute. I cannot prevent him to select such a combination of parameters (it's quite legal), so I'd like to set a timeout on the query. Note that I really want to stop the query execution itself and rollback an...

Classic ASP retrieving large amounts of data

I have a table that has over 148,000 rows, I have managed to display this by doing: <%response.Buffer=false%> However, this is far from ideal as it needs to be done on the server and it takes so long. Is there a better way of doing this? Many Thanks, Joel ...