sql-server

Can I get name of all tables of SQL Server database in C# application?

I want to get name of all table of SQL Server database in my C# application. Is It possible? Plz tell me Solution. ...

Updating a sql server table with data from another table

I have two basic SQL Server tables: Customer (ID [pk], AddressLine1, AddressLine2, AddressCity, AddressDistrict, AddressPostalCode) CustomerAddress(ID [pk], CustomerID [fk], Line1, Line2, City, District, PostalCode) CustomerAddress contains multiple addresses for the Customer record. For each Customer record I want to merge the most...

How to query on table returned by Stored procedure within a procedure.

I have a stored procedure that is performing some ddl dml operations. It retrieves a data after processing data from CTE and cross apply and other such complex things. Now this returns me a 4 tables which gets binded to various sources at frontend. Now I want to use one of the table to further processing so as to get more usefull inform...

Incorrect value for UNIQUE_CONSTRAINT_NAME in REFERENTIAL_CONSTRAINTS

I am listing all FK constraints for a given table using INFORMATION_SCHEMA set of views with the following query: SELECT X.UNIQUE_CONSTRAINT_NAME, "C".*, "X".* FROM "INFORMATION_SCHEMA"."KEY_COLUMN_USAGE" AS "C" INNER JOIN "INFORMATION_SCHEMA"."REFERENTIAL_CONSTRAINTS" AS "X" ON "C"."CONSTRAINT_NAME" = ...

What is the purpose of ROWLOCK on Delete and when should I use it?

Ex) When should I use this statement: DELETE TOP (@count) FROM ProductInfo WITH (ROWLOCK) WHERE ProductId = @productId_for_del; And when should be just doing: DELETE TOP (@count) FROM ProductInfo WHERE ProductId = @productId_for_del; ...

The best way to return related data in a SQL statement

I have a question on the best method to get back to a piece of data that is in a related table on the other side of a many-to-many relationship table. My first method uses joins to get back to the data, but because there are multiple matching rows in the relationship table, I had to use a TOP 1 to get a single row result. My second met...

cloning a database with backing up possible?

I need to write a tool to clone a database, instead of detaching it and copying the .mdf and .ldf, wouldn't it be better to just back it up and restore a newly created db? Is there a way using SQL to create a database from a .bak? ...

SSRS Calculating counts across row and column groups

I'm building a report of case results with a parent-child grouping on the row group and single column grouping: Parent Row Group: Location Child Row Group: Result Column Group: Month Running across the report are months in the year, and running down the report are the location and the different result breakdowns for the location in...

Connection Strings between Web Application and SQL Server

Greetings. I'm writing a web application that is supposed to connect to a SQL Server database; the connection is formed from the following database string: <add key="DatabaseConnectionString" value="server=DEVPC1\SQLEXPRESS;uid=USERID;pwd=PASSWORD;database=DATABASE"/> However, whenever I try and run the web application, I get a conne...

Where to start in profiling SQL server Silverlight application

Hi, I need some advice on where to start in profiling a silverlight 3 application that is loading data from a SQL server Express database. At this stage I am not sure if the querying of the data on the server is taking long (and we may need indexes) or if loading on the client side is the problem. How would one start? JD. ...

How hard is it to determine what procedures/functions no longer compile?

In sql server how difficult would it be to determine what procedures/functions no longer compile? In other words, if I scripted out alter statements for all procedures and functions in a database, I'd like to know which of these statements are going to fail? I've been working on cleaning up a database I've inherited which has gone thro...

Does SQL Server 2005 pass error message numbers back to the asp.net application?

I'd like to get the message number and severity level information from SQL Server upon execution of an erroneous query. For example, when a user attempts to delete a row being referenced by another record, and the cascade relationship is "no action", I'd like the application to be able to check for error message 547 ("The DELETE stateme...

Linq to SQL Problem System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager

I have a really tricky thing going up here. My project has around 100 tables and they are all mapped by LINQ. Everything works fine in a dev and test environment. These enviroments are MS Win 2008 r2 servers with SQL 2008 sp1 databases. IIS and SQL are on a different machines. Now on production enviroment which is MS Win 2003 x64 web far...

SQL CLR Assembly Error 80131051 when late binding to a registered C# COM .dll

I must have hit an unusual one, because I can't find any reference to this specific failing anywhere... Scenario: I have a legacy SQL function used to transform(encrypt) data. This function is called from within many stored procedures used by multiple applications. I say this, because the obvious answer of 'just call it from your cod...

Select the column names from one table and Corresponding data from another table

I have 2 tables: ColumnDefinition : column names will store ColumnData: corresponding columniD(column name) we will insert the data. I need one select statement with column names and with data as a DataSet.( out put may also XML ) TABLES: FormColumDefinition ------------------------------ formColumnID formColumnDataType formColum...

MS SQL Server Text Datatype Maxlength = 65,535?

Software I'm working with uses a text field to store XML. From my searches online, the text datatype is supposed to hold 2^31 - 1 characters. Currently SQL Server is truncating the XML at 65,535 characters every time. I know this is caused by sqlserver, because if I add a 65,536th character to the field directly in Management Studio, ...

SQL Server and Android

Is there any way to connect to a SQL Server from an Android application and execute/query SQL statements without Web Service/WCF etc? Thanks. ...

SQL Server 2005: Update rows in a specified order (like ORDER BY)?

I want to update rows of a table in a specific order, like one would expect if including an ORDER BY clause, but SQL Server does not support the ORDER BY clause in UPDATE queries. I have checked out this question which supplied a nice solution, but my query is a bit more complicated than the one specified there. UPDATE TableA AS Parent...

String update in SQL Server

Currently I have varchar field. The delimiter is "$P$P$". The delimiter will appear at least once and at most twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, I need to insert a text before the second occurance of the de...

Why there is a difference in query results?

SELECT count(*) FROM Table1 t1 SELECT count(*) FROM Table1 t1 Where t1.ID not in (select ID from Table2) SELECT Count(*) FROM Table1 t1 inner join Table2 t2 on t1.ID = t2.ID Results:- 83 62 26 Why there is difference in results of 2nd and 3rd query when total is 83 from Ist Query? Is it not supposed to be either 57 (from 2nd que...