sql-server

Why are my Chinese characters not displayed correctly in c# string

I am storing Chinese and English text in an SQL Server 2005 database and displaying it on a webpage, but the Chinese is not being displayed correctly. I have been reading about the subject and have done the following: used N before the text in my INSERT statement set the field type to nvarchar set the charset of the page to UTF-8 Chi...

SQL: No Identity feature workaround using triggers, Any Help?

I'm a little rusty with my triggers and what not and am trying to figure out this problem for a class: In a database TEST, tables do not have the option of the IDENTITY feature. In other words, when we insert a row into the table “Users”, we would like the primary key “UserID” to auto-increment. Please suggest a workaround to implement ...

stored procedure returns varchar

I would like to know if in SQL is it possible to return a varchar value from a stored procedure, most of the examples I have seen the return value is an int Example within a proc declare @ErrorMessage varchar(255) if @TestFlag = 0 set @ErrorMessage = 'Test' return @ErrorMessage ...

ùser mapping query

Hi, I want to know how to get user mapping details in sql server 2005,whether the login user has the permission on the database or not. ...

SSIS Union All problem - is there a bug in SSIS for this item?

I am using SQL 2005 and SSIS.............. I have 2 data sources. One from table A and one from table B. I want to move data from table A to table B. But first i get the MAX date from both and compare them. If they are the same then i must either stop the SSIS package or use the Conditional Split. But when the MAX date from table B g...

Using SqlServer uniqueidentifier/updated date columns with Linq to Sql - Best Approach

Rightly or wrongly, I am using unique identifier as a Primary Key for tables in my sqlserver database. I have generated a model using linq to sql (c#), however where in the case of an identity column linq to sql generates a unique key on inserting a new record for guid /uniqueidentifier the default value of 00000000-0000-0000-0000-000000...

Using views in a datawarehouse

I recently inherited a warehouse which uses views to summarise data, my question is this: Are views good practise, or the best approach? I was intending to use cubes to aggregate multi dimensional queries. Sorry if this is asking a basic question, I'm not experienced with warehouse and analyis services Thanks ...

ASP.Net MVC - route object id == title - how to deal with duplicates?

Web pages have moved to use URLs like: //weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx i.e. they include the title of the page in the url rather than having some coded id. I understand that this is useful for SEO, and also for users in finding the correct page where they wish to type in the...

Convert a date and time into a MS SQL select query using SelectParameters

Hi all, I have this situation where I have a SqlDatasource control and the select query is like: SELECT col1, col2 FROM table1 WHERE colDate = @date The source of @date is a label with the text: 2009-05-29 12:06:00 I get the following error when I run the query: Conversion failed when converting date and/or time from character ...

Querying multiple databases on SQL Server

Hi is it possible to create a view that selects from multiple tables in different databases on different servers using different login credentials Can someone point to any online examples. Or is there any way I can do it using Linq if I cant create a view ...

How to find foreign key dependencies in SQL Server?

How can I find all of the foreign key dependencies on a particular column? What are the different alternatives (graphically in SSMS, queries/views in SQL Server, 3rd party database tools, code in .NET)? ...

Combine fields from joined tables

One category can have many products. I have to build StoredProcedure that returns all categories with some data from Products combined into one field: SP Result: idCategory Name ProductNames ProductQuantities 1 Cat1 Procut1,Product2 24,32 2 Cat2 ProductX,ProductY 0,61 ProductNames and Product...

Retrieving auto-incremented column value from table where multiple insert/selects in single stored procedure

I have a stored procedure with multiple insert/select statements. Let's say I'm using the first insert to populate a "Manager" table. On insert, a ManagerId (incremented automatically) is added, but not referenced in the insert statement. I then wish to use the ManagerId from this table to insert a row into another table, where Manage...

In SQL Server, how can I select all records in a recursive table?

I have a recursive table in which each record has an ID and a PARENTID. PARENTID points to a different ID in the same table. Is there a way in SQL Server to select an entire "tree" in one statement? I could write a recursive function to jump from a parent to all the children, but I'd like a way to do it in one query. In Oracle, it wo...

How to attach a database without an LDF file?

How can I attach a database without an LDF file in SQL Server? ...

How can I select only common properties from a results set?

Lets say I have a table with columns such as: ID Name City State ZIP I need to write a query that will return only one row. This row will include City, State, and ZIP, but I only want a field to have a value if all values in the results set are the same, otherwise I want the field to be null. For example, if every record has the sam...

Query Transposing certain rows into column names

Hi all, I have a couple of tables which look like this Table 1 user_id | name ------------------------- x111 | Smith, James x112 | Smith, Jane etc.. Table 2 id | code | date | incident_code | user_id ----------------------------------------------------------------- 1 | 102008 | 10/2...

Are my issues with SSIS justified?

I've only been using SSIS briefly, but I find that my complaints are numerous. Here are my current issues: In order for a package to store a password, you need to encrypt it. Even if the package is part of a larger solution, you need to supply a password anytime to open any of the encrypted packages. Why can't you just encrypt the w...

Is it possible to restrict the number of connections for a role/login in SQL Server 2005?

e.g. Make it so that you could limit it to a max 2 connections for a given technical account, the third connection being blocked repeatedly until one of the others is given up ...

Testing linked server conccetion inside trigger or procedure

I wrote a trigger that updates local table and similar table on linked server. CREATE TRIGGER myTtableUpdate ON myTable AFTER UPDATE AS IF (COLUMNS_UPDATED() > 0) BEGIN DECLARE @retval int; BEGIN TRY EXEC @retval = sys.sp_testlinkedserver N'my_linked_server'; END TRY BEGIN CATCH SET @retval = sign(@@error); END CAT...