sql-server

how to bind asp.net controls using a self join and items tables "hierarchically structure"?

I have the following tables: 1-Categories: -CategoryID -CategoryName -ParentID 2-Items: -ItemId -ItemName -CategoryID categories can be in a hierarchically view, with many children categories inside each other. And any the last child category can have items, so just the last category child will show items under it. The view will be lik...

Security vulnerabilies checklist

I am working on a consumer facing web application built on .Net/C# MSSQL as the databse We have been following general good coding practices to prevent bugs and SQL/JS query injections but non of us are experts on security. What would be a good checklist to find out how really secure is the application we are building. ...

SQL Server: Sanitizing @param against injection attacks

For the sake of argument, let's just say I have to create a local variable containing a SQL query that has an INSERT: DECLARE @insert NVARCHAR(MAX) SELECT @insert = 'INSERT INTO [dbo].[' + @table + '] VALUES... EXEC (@insert) This INSERT is also going to contain a column value: DECLARE @insert NVARCHAR(MAX) SELECT @insert = 'I...

SELECT DISTINCT

I'm working on an SSIS package where I'm importing data from a CSV file into a SQL table. The only field that I'm concern with is the Username. This Username must be unique. I don't care whether first name or last name are the same or not. In the package, I imported the data from file into a temp SQL table. And then I used SELECT DISTI...

Looking for good tool to convert Oracle - sql server

Hi I'am looking for good tool that can convert from Oracle to sql server and from sql server to oracle. I found some, but there was many errors during the conversion thank's in advance ...

What is the best way to save XML data to SQL Server?

Is there a direct route that is pretty straight forward? (i.e. can SQL Server read XML) Or, is it best to parse the XML and just transfer it in the usual way via ADO.Net either as individual rows or perhaps a batch update? I realize there may be solutions that involve large complex stored procs--while I'm not entirely opposed to this,...

How do I clear the dropdown of logins from the sql server 2008 management studio conection prompt?

I've connected to a few databases once and only once and will never need to again, however they clutter up the dropdown of logins available to select. How can I reset the lists of servers and logins from the connection prompt in SQL Server Management Studio Express 2008? ...

Access SQL Server from Solaris

I found out about the freeTDS which can be used here, but there are doubts about its stability in the production environment. Is there any other way to interactive with MSSQL Server from Solaris besides using ODBC driver? ...

SQL Server 2008 remote connection only works once

When I connect to the SQL Server 2008 remotely it only works once, after that the server hangs. The service cannot be stopped or restarted and when trying to connect again it gives a 'Timeout' error. The server has TCP/IP connections enabled. The default port is set to 1433 and I cleared the 0 from the dynamic ports. I enabled the 127.0...

Adding a new dimension based on a key in fact table linked to one of the dimension tables

Hi, I have a fact table that holds all date & time attributes as keys which links to actual DATE & TIME dimension. When I create a cube on top of it using SSAS 2005, these datetime attributes are split into individual dimensions for the CUBE, which is OK. Problem is when I add a new datetime attribute to the fact table, my cube doesn't ...

Sql Server time 1 hour behind

I have a datetime column in a table called 'createdDate' were the default value is set to getutcdate(). However when a row is added to the table the createdDate's time value is 1 hour behind the system time. So my question is how do I increase the current database system timestamp by 1 hour? Thanks in advance. ...

what is use of operators and alerts in sqlserver nmanagement studio

Hi Can any one explain whyand where to use operators and alerts in sqlserver nmanagement studio ...

Hidden features of SQL Server 2009 AF edition and mySQL9.1.4 - fuzzy logic

It was reveled today that the new standard of SQL will include specification of some new database operations that will allow using databases for Fuzzy Logic operations. This new functionality is said to be implemented in SQL Server 2009 AF Edition and mySQL9.1.4 There were 2 new keywords introduced The new keyword is called JOINT which...

Visual Studio 2008 Database Addon

I am currently trying out visual studio to access sql server databases instead of using SQL Server Management Studio. It was a good surprise how easy it is to setup and use a connection do a database and for the moment it has a positive impact on my productivity. My question is: Is there an addon (or something i can do) to enable intel...

What happens when I drop a clustered primary key in SQL 2005

I've a PK constraint - a clustered index on two columns - which I am in the process of dropping. The command is still running after an hour. I would have thought that as I am just removing a constraint the operation would be nearly instantaneous. Can someone explain to me what is actually happening under the hood when I drop the PK? ...

How to get MAX value of numeric values in varchar column

I have a table with a nvarchar column. This column has values for example: 983 294 a343 a3546f and so on. I would like to take MAX of this values, but not as text but like from numerics. So in this example numerics are: 983 294 343 3546 And the MAX value is the last one - 3546. How to do this in TSQL on Microsoft SQL? ...

How to write this SQL Statement

table1 has 3 columns: Id UserName SubmittedDate 1 Joe 1/1/2006 2 Joe 1/1/2007 3 Nat 1/1/2008 4 Pat 1/1/2009 I want to return this: Id UserName 2 Joe 3 Nat 4 Pat I just want just one record for Joe, the most recent one. How do I write this query? Thanks ...

SQL select value if no corresponding value exists in another table

I have a database which tries to acheive point-in-time information by having a master table and a history table which records when fields in the other table will/did change. e.g. Table: Employee Id | Name | Department ----------------------------- 0 | Alice | 1 1 | Bob | 1 Table: History ChangeDate | Field ...

Getting return value from stored procedure in C#

I have the following query: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[Validate] @a varchar(50), @b varchar(50) output AS SET @Password = (SELECT Password FROM dbo.tblUser WHERE Login = @a) RETURN @b GO This compiles perfectly fine. In C#, I want to execute this query and get the return value. My code ...

Get schema of proc's select output

I'd like to put the results of a stored proc into a temp table. It seems that the temp table must be defined beforehand and an INSERT INTO will not work. Anyone know how to get the schema of the recordset being returned from a select statement? sp_help only gets info on parameters. ...