sql-server

SQL Server: get all parent child URL's from a single table

I have a table that looks like this: Slug | Parent | MetaTitle | MetaDescription | MetaKeywords The Url's on the site are built by appending the slug to the parent as long as the parent is not null. So if I have data like so: Slug | Parent ----------------------------------------- Home null About n...

sql server 2005 problem - defrag necessary?

Hi, I insert some data into a sql server 2005 database using NHibernate. Before I insert an object I check whether it already exists based on its primary key. Every 100000 or so lookups this seems to throw some exception (if I do the same via sql it takes ages as well). A defragmentation of the hard disk seems to help but seems a bit st...

How To find the Changes happened to the SQL Server since last Migration

Hi All, I am in a situation where I need to find the Changes happened to the database since last migration. Eg: Changes happened to the Stored Procedure,and Views and functions. How Can I find these Changes. We are not using any third Party Tools. Please can any one help me out on this. Thanks in Advance. Venkat ...

T-SQL query to remove non matching value from ColumnA where value doesn't exist in ColumnB

I have two databases, with the following tables: DatabaseA TableA ColumnA (varChar(10) DatabaseB TableB ColumnB (varChar(10) I need a query that: Ignores NULLs or empty strings Finds rows where the value of ColumnA does not exist in columnB In this case, replaces the value of the non matching row in ColumnA with '' (empty string)...

Database Schema Change and Entity Framework 4 in Release Production Environment

OK, here we go, after reading a couple of related questions, I haven't ended into a real productive solution for my thoughts. Thoughts: As we all developers creating applications, then these apps going into production, the client after couple of days demands additional features. Great! you open your database through Server Explorer, c...

Diff on SQL Server XML Data Type?

I have an automated process that inserts an XML document into SQL Server 2008 table, the column is of Type XML. There is a lot of duplicated data, I wonder if anyone can recommend a good way to delete non-distinct values based on the XML column? The table has thousands of rows and each XML document is about 70k. Each XML document looks ...

SQL what is wrong with the syntax here?

What is wrong with the syntax in this function? I am getting the following errors: ALTER FUNCTION [dbo].[udf_ReportingLevelStructure2] ( @CompanyID INT ) RETURNS @result TABLE ( CompanyName VARCHAR(300), [rl_Index] INT, [rl_Addr1] VARCHAR(MAX), [rl_Addr2] VARCHAR(MAX), [rl_DisplayName] VARCHAR(MAX) ) AS BEGIN ...

Stored Procedure and Permissions - Is EXECUTE enough?

I have a SQL Server 2008 database where all access to the underlying tables is done through stored procedures. Some stored procedures simply SELECT records from the tables while others UPDATE, INSERT, and DELETE. If a stored procedure UPDATES a table does the user executing the stored procedure also need UPDATE permissions to the affec...

Entity Framework - how to get database column datatype from metadata

Is there a way to get the database column DataType length information given a table's EntityType? Example SQL (SQL Server) that you can run to see precisely what information I am looking for: select sys.tables.name as 'Table Name', sys.columns.name as 'Column Name', sys.systypes.name as 'DataType', sys.columns.max_l...

tutorial on connecting c# to sql server

i want to be able to edit a table in a sql server database using c# can someone please show me a very simply tutorial on connecting to the DB and editing data in a table thank you so much ...

Visual Studio 2008 doesn't connect to SQL Server 2008

When i try to establish a connection with SQL Server 2008 i am getting: The server version is not supported. only servers up to SQL Server 2005 are supported. What's wrong with this? is there a patch? ...

delete from two table having foreign key constraint

I have two tables in my database and the t1 table primary key is uid, t2 table a foreign key name desg. now I want to delete or update this uid in one table give error that Now row was updated. data in the row was not committed. error source:.netSqlclient data provider. error message: the update statement conflicted with th...

extract data from a dataset

I have a dataset that gets populated from a stored proc in sql server. I have a column that has lets say has a set of values. I do not know what those values are. All I know is that they of the type "string". I want to extract all the distinct values from that column. ...

Adding an autonumber to a SQLcolumn which has more than 15 million records

I need to add a autonumber column to an existing table which has about 15 million records in SQL 2005. Do you think how much time it'll take? What's the better way to do it? ...

to debug this project you must enable sql/clr

i am running a script from visual studio 2008 to a sql server 2008 connection i am getting this message when i build: to debug this project you must enable sql/clr debugging for the connection. note that during debugging all managed threads on the server will stop. is this dangerous to do given that i have other databases on this ser...

My query filtering is not working the way I want it to

I have 3 ways I want to filter: by name by list and show all I'm using ASP.NET 3.5 and SQL Server 2008. Using ADO.NET and stored procs. I'm passing my list as a table valued parameter (but I'm testing with a table variable) and the name as a nvarchar. I have "show all" as ISNULL(@var, column) = column. Obviously the way I'm query...

Tutorial on displaying datasets from a SQL Server database using C#

I am using Visual Studio 2008 and I am a beginner. I am connecting to a SQL Server 2008 database. I would like to display data from a table. How do I do this? Can someone please show me an easy tutorial? ...

choosing table design for database performance

I am developing a Job application which executes multiple parallel jobs. Every job will pull data from third party source and process. Minimum records are 100,000. So i am creating new table for each job (like Job123. 123 is jobId) and processing it. When job starts it will clear old records and get new records and process. Now the probl...

What happens when I update SQL column to itself? -OR- simplified conditional updates?

I would like to call an "update" stored procedure which won't necessarily include all columns. There is probably a better way to handle this.... As you can see, if I do not pass in the column parameters their value is NULL. Then, using the ISNULL, I set the columns either to their new values or their existing values. CREATE PROCEDURE [d...

Permissions when using "Execute sp_Executesql"

I have a database where all access is controlled by stored procedures. The DBA would like to avoid giving users direct read/write access to the underlying tables, which I can understand. Hence all updating and selecting of data is done via stored procedures. Basically he has created one role that has EXECUTE permissions to all the stored...