sql-server

BCP: Unable to resolve column level collations

Running this: bcp MyDb.dbo.uvwMyView out "c:\Test.txt" -SMyServer -T -c I get this error: SQLState = S1000, NativeError = 0 Error = [Microsoft][SQL Native Client]Unable to resolve column level collations Searching google finds many possible solutions, none of which work for me or have worked for any of the people they were proposed...

SQL Server Replication (cross-database queries & constraints)

We want to replicate data from one database to several others (on another server). Would it make sense to replicate these tables to a shared database on the other server and have our cross-database queries reference the shared database... or would it make more sense to replicate out to each individual database on the other server? Would ...

Can SSIS ScriptTask References resolve to a non GAC location?

In SSIS 2008, the ability to reference other class libraries has been added. Is there anyway to resolve the references to a non-GAC location when deployed to a non-developer environment? For instance, if I add a reference to c:\lib\mylib.dll in an SSIS script task then deploy that package to another machine. Can I simply place mylib.dll ...

SUM/GROUP performance and the Primary Key

I have a table myTable with myGuid (uniqueidentifier), myValues (float), myGroup (integer) and a bunch of other fields which are not important right now. I want to do something as simple as: SELECT SUM(myValues) FROM myTable WHERE myGuid IN (SELECT * FROM ##test) GROUP BY myGroup ##test is just a temporary table with a single fiel...

What's the best way to implement a search?

I've got a requirement where a user enters a few terms into a search box and clicks "go". Does anyone have any good resources on how to implement a dynamic search that spans a few database tables? Thanks, Mike ...

SQL Server - Nested Query

Hello, I have a query that I'm not sure how to write. I'm not a SQL expert and it's pretty nasty. I'm hoping someone here can help me with it. I have a table called "Members" which has a list of user names to my web site. I need to get the list of users that belong to one or more divisions in my company as well as one or more managers....

SQL Server: Persistant "Cache" Table Across Connections

I have a set of approx 1 million rows (approx rowsize: 1.5kb) that needs to be "cached" so that many different parts of our application can utilize it. These rows are a derived/denormalized "view" of compiled data from other tables. Generating this data isn't terribly expensive (30-60sec) but is far too slow to generate "on the fly" as...

Can i use Cursor within userdefined function In sql server 2005 manage code?

By using cursor i want to make one virtual table. and after that using function i want to use that virtual table format and pass value of original table and then.. i show.. virtual table.. into output.. ...

Set below query into asc or desc order in mysql?

SELECT * FROM (SELECT ROW_NUMBER() over ( ORDER BY CASE WHEN @SortExpression ='Country_id' THEN Country_id END, CASE WHEN @SortExpression ='Country_name' THEN Country_name END, CASE WHEN @SortExpression ='Country_region' THEN Country_region END, CASE WHEN @SortExpression ='Country_area' T...

SQL Server: Copy Stored Procedures

Is there an easy way to copy all stored procedures from one database to another? I have SQL Management Studio installed. ...

SQL Server 2008 x64bit Mode

I am attempting to query a SQL 2008 x64 database from a SQL 2008 x64 database. All attempts have failed, whether using Linked Server or OpenQuery. To create the Linked Server entry I have used the linked server dialog, the script it creates and the sp_AddLinkedServer procedure. The error occurs whether I use Windows Authentication or the...

Get Last page no in a pager link like stackoverflow

How to get last page no like stackoverflow.com pagination in Sql server 2005 ...

Help with a complex self referency query accross multiple colums

I am having difficulties with a complicated (for me any way) query. The table I'm querying has 3 colums, ClientID (int Not Null), ProductID (int Not Null) and ExpiryDate (smalldatetime nullable) Given two client ID's Master and Consolidated I need to perform the following business logic to return a single data set: Select the Clien...

Pls modify this code for retrieving the image from sqldatabase

I am still suffering from retrieving an image from a SQL database. This is my final solution for inserting and retrieving an image from database. Here is all my code: GUI part: <div> <asp:Label ID="lblImage" runat="server" Text="Image"></asp:Label> &nbsp;&nbsp;&nbsp;&nbsp; <asp:FileUpload ID="imageUpload" runat="server" /> ...

ASP.NET user browse selected/restricted raw data from sql-server

In an ASP.NET WebForms application I would like to allow the end-user to browse selected raw data in an sql-server database. However, I would like to restrict access for the user to only view some of the data based on the username. I'm not sure how to do this in a way that is possible for the user to understand, since SQL is not necess...

How to retrieve all the data and log files of mirror database?

while retrieving data and log files of Mirror Database(Ex:TestDB) using EnumFiles() of sql dmo seeing following error: ERROR: Microsoft SQL-DMO (ODBC SQLState: 42000) [Microsoft][ODBC SQL Server Driver][SQL Server]The database "TestDB" cannot be opened. It is acting as a mirror database. so can anyone please tell me how to retrieve all...

SQL Server Linked Server

All, I am trying out a new linked server - I can run this command fine: SELECT * FROM NextGen4.NGEPMWareHouse.dbo.Network_People If I try to get fancy (update a table on my local server from the linked server) UPDATE dbo.Network_People SET dbo.Network_People.NGTimeStamp = NextGen4.NGEPMWareHouse.dbo.Network_People.[TimeStamp] WHERE ...

copy data from one table to another with different primary key

Hi, I have to migrate data in sqlserver from one table to another. Most of the standalone table were possible with select and insert into sp's. The issue is in one table from the old database there is a column with a primary key say unit. Now this unit is divided into two parts in the new database for example 'industry' and 'resource'...

Optimal code - One large query but more complicated data retrieval or lots of small queries

Hi, I have a C# program that retrieves multiple rows from a DB but currently does them one at a time on the same connection. Would it be better to write it so that instead of repeatedly running (where blah changes each time): select data from table where name = 'blah' To something like: select name, data from table where name in (...

Sql server 2005 needs daily index defrag

Our production database needs daily index defragmentation on one of its tables. The table has several indexes and one of them will get to 90% fragmentation each day. The index is on two date fields ( a start time and an end time). We do not get this problem on our development database although this obviously has a much lower throughput...