Hello All,
How can I do the following in SQL Server
DECLARE @Local nvarchar(20)
SET @Local = 'True'
SELECT * FROM My_Table
WHERE my_ID IN
(IF @Local = 'True'
SELECT AllIDs FROM ATable
ELSE
SELECT TeamIDs FROM TeamTable
)
...
New to VB.Net,
How to insert or select the dataset value.
cmd = New SqlCommand("Select * from table1", con)
ada = New SqlDataAdapter(cmd)
ds = New DataSet
ada.Fill(ds)
cmd = New SqlCommand("Select * from '" & ds.Tables(0) & "' ", con)
mydatatable1.Load(dr3)
It was showing the error in '" & ds.Tables(0) & "',...
I am trying to round to 3 decimal places from two variables of type money in SQL Server 2008.
DECLARE @Val1 money = 554.5344
DECLARE @Val2 money = 84020.37
DECLARE @Result decimal(6,5) = @Val1/@Val2 *100
SELECT @Result
The result above is 0.65. With a calculator it is 0.65999995001212, I need the result to be 0.659.
...
How can we dis-connect all the active users on sql-server 2005 express using sql
...
how would you get the 5 value from a row of data.
...
There is quite often situation when you need to execute INSERT, UPDATE or DELETE statement based on some condition. And my question is whether the affect on the performance of the query add IF EXISTS before the command.
Example
IF EXISTS(SELECT 1 FROM Contacs WHERE [Type] = 1)
UPDATE Contacs SET [Deleted] = 1 WHERE [Type] = 1
Wha...
Hi,
I have a clinet sdf file (sql compact) that is created by the LocalDataCache.sync in Visual Studio 2008. The server is SQL Server 2008.
On the server if I do the following:
CREATE TABLE test (
[firstfield] float NOT NULL DEFAULT 1,
[secondfield] float NOT NULL DEFAULT 2)
GO
INSER...
Hi everyone, I have a strange problem. The SQL server data access works fine in the main thread but fails if i call the same from a background worker thread. Please help. I dint find anything on the net except i that suspect HostProtectionAttribute of BackgroundWorker.
When i try to open the connection on the background thread i get the...
What would be the best method to use for testing that connection managers are correctly pulling their connection strings from the package configurations on multiple packages (In VS 2008). In the past I have created a data flow which ran the query select @@servername and outputed to a text file. While this works, it seems a bit redundan...
I have a field of type TimeStamp in database, which is converted in byte[] in c# code, and i need to convert it to DateTime value.
So i want to convert from an array of bytes into DateTime.
Already used this code:
byte[] byteValue = someValue;
long longVar = BitConverter.ToInt64(byteValue);
DateTime dateTimeVar = DateTime.FromBinary(lo...
I have a column TypeCode varchar(20) that has values like '1', '2', '3', 'FOO', 'BAR'. I need to find the maximum integer which is less than the value of parameter. Something like this:
select max(TypeCode) TypeCode
from table1 a
left join table2 b on b.table1id = a.id
and b.TypeCode not in ('FOO', 'BAR')
where b.Typ...
I'm writing T4 templates to generate CRUD stored procs etc
I am looping through the columns of a table using SMO:
For Each column As Column In table.Columns
WriteLine("@" & column.Name & " " & column.DataType.Name & ", ")
Next
My question is simply how do I find the Length of a varchar column? There doesn't appear to be any Lengt...
Are there any good options for connecting two SQL Server 2008 instances via Service Broker if neither of those servers are in a domain, but we have full control over the logins and credentials?
We're thinking of using this technology for enterprise-level data consolidation, but our servers run at client sites and are not configured as m...
Is there a way of determining when a given user last logged into SQL Server? We are about to carry out an audit of our database server and would like to delete users that are redundant.
Incidentally I'm interested in users at the server-level (i.e. Logins), not users of individual databases.
Thanks in advance.
...
I have a WCF service hosted within IIS that logs information in a sql server 2008 db. I have successfully tested this within my local IIS and SS2008 db (using an application pool running under my windows id).
Now I have moved the database and wcf service to the production server and wondering how to set the security up on the database t...
I am using SQL Server 2008 express version but don't know how to generate database diagrams. When I click the Database Diagrams, it give me an error diagram tell me "Database diagram support objects cannot be installed because this database does no thave a valide owner. ...." I follow its instruction and cannot find anything wrong. Anybo...
I'm working with SQL Server 2008. Is it possible to alter a computed column without actually dropping the column and then adding it again (which I can get to work)? For example, I have this table:
CREATE TABLE [dbo].[Prices](
[Price] [numeric](8,3) NOT NULL,
[AdjPrice] AS [Price] / [AdjFactor],
[AdjFactor] [numeric](8,3) NOT NULL)
La...
I am trying to find out whether a database has a catalog or not. I couldn’t find any system stored procedure to perform this task.
I need to find the catalog first then perform Full text search. If a catalog is not found, full text search is ignored.
...
How to take the backup of live sql server 2005 express DB ? At any given time some transaction are in progress.
...
I am developing a new web application using .NET 3.5 and SQL Server 2008 that will need to store some Social Security Numbers. I've been doing some initial reading on database encryption and it's a little bit confusing.
I would be nice to encrypt the SSNs using an asymmetric key, since that way the public facing application wouldn't be ...