How to check if the global Temporary table exists in SQL server, if yes then delete that global temporary table?
I am trying to execute this:
IF OBJECT_ID('##Table', 'U') IS NOT NULL
DROP TABLE ##Table
...but it is not working.
...
I have a question about using databases...
string node = Session["node"].ToString();
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = ConfigurationManager.ConnectionStrings["SumooHAgentDBConnectionString"].ConnectionString;
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dat...
I am trying to write T-sql script which will find "open" records for one table
Structure of data is following
Id (int PK) Ts (datetime) Art_id (int) Amount (float)
1 '2009-01-01' 1 1
2 '2009-01-05' 1 -1
3 '2009-01-10' 1 ...
Is there a way in SQL Server to list all the views within a database that join from a particular object?
ie: find all the views that join from the table myTable
...
Hello folks!
I need to create in my DB a log, that every action in the program should be written there.
I will also want to store additional data to it for example have the table and row the action was applied to.
In other words I want the log to be dynamic and should be able to refer to the other tables in the database.
The problem i...
I'm trying to insert some text data into a table in SQLServer 9.
The text includes a single quote.
How do I escape that?
I tried using two single quotes, but it threw me some errors.
eg. insert into my_table values('hi, my name''s tim.');
...
Hi guys,
I have two columns of data in a SQL 2005 DB
Datetime Value
'2009-10-29 10:00:00' ' 10.1'
'2009-10-29 10:15:00' ' 10.2'
'2009-10-29 10:30:00' ' 10.3'
'2009-10-29 10:45:00' ' 10.4'
I want to
SELECT Value
FROM [table]
WHERE Datetime >= '2009-10-29 10:00:00'
AND (Datetime NOT BETWEEN '2009-10-29 10:14:00' AND '20...
I'm trying to get some values out of an Xml Datatype. The data looks like:
<Individual xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FirstName xmlns="http://nswcc.org.au/BusinessEntities.Crm">Lirria</FirstName>
<LastName xmlns="http://nswcc.org.au/BusinessEntiti...
I have to write a query to delete form 2 tables
DELETE FROM [Policies],[BackupSpec] WHERE [PolicyID] = @original_PolicyID
PloicyID is PK in Policies
and FK in Backupspec
any suggestions??
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["SumooHAgentDBConnectionString...
In a database where all of your primary keys are GUIDs, what are the differences/implications and/or pros and cons using newid() versus newsequentialid() as the "default value or binding".
The only difference that I know of is that newid() creates a new random GUID as opposed to newsequentialid() creates a new GUID based on the last one...
I have just had a scheduled SQL Server job run for longer than normal, and I could really have done with having set a timeout to stop it after a certain length of time.
I might be being a bit blind on this, but I can't seem to find a way of setting a timeout for a job. Does anyone know the way to do it?
Thanks
...
I'm trying to use ContainsTable to return a ranked list of results.
I have it working fine when it finds a whole word match but its doesnt seem to work for partial words. For example if I search for 'acq' it wont find 'Acquisitions'. I really need it to work with partial matches for it to be useful. Using "Like" is not an option as the...
How can an application, running on a production server, access the login username of the machine that a user is accessing an application from? For example, I am currently logged into my machine on the INTRA corporate intranet. My username will be INTRA\Username.
I have added specific usernames to a database and wish to check this in...
I have two databases: the source is a database from SQL Server Express by client and the target is a database from SQL Server 2005 database as backup initially. What I need is to sync the source to the target db if there is any difference between them and the sync is one-way from source to target.
I am not sure what tools are available....
In SQL Server 2005 I have a table with data that looks something like this:
WTN------------Date
555-111-1212 2009-01-01
555-111-1212 2009-01-02
555-111-1212 2009-01-03
555-111-1212 2009-01-15
555-111-1212 2009-01-16
212-999-5555 2009-01-01
212-999-5555 2009-01-10
212-999-5555 2009-01-11
From this I would like...
Hi i am using the following dynamic sql:
declare @cmd nvarchar(4000)
set @cmd=
'select ''exec msdb.dbo.sp_update_job @job_id=''''''
+ convert(nvarchar(255), job_id)+ '''''',
@owner_login_name=''''sa'''';''
from msdb..sysjobs'
exec sp_executesql @cmd
but all it is doing is printing as exec .......
I want to execute the results ...
When I do this:
select col1,case when [pivot1]=1 then '-' else '' end [pivot1],
case when [pivot2]=1 then '-' else '' end [pivot2]
from
(select col1,col2,col3 from tbl) as c
pivot
(sum(col3) for col2 in
([pivot1],[pivot2]))as pvt
Everything works fine.
When I do this:
select col1,[pivot1],[pivot2]
from
(select col1,col2,col3 from tb...
I'm writing a C# application to generate an SSIS package.
Part of this involves adding database connection managers - using the library Microsoft.SqlServer.Dts.Runtime. The following line of code shows how this can be done:
ConnectionManager cm = pkg.Connections.Add("OLEDB");
In the above code, I am adding an OLEDB connection, which ...
I have the following SQL table,
Id WindSpeed DateTime
--------------------------------------
1 1.1 2009-09-14 16:11:38.383
1 1.9 2009-09-15 16:11:38.383
1 2.0 2009-09-16 16:11:38.383
1 1.8 2009-09-17 16:11:38.383
1 1.7 2009-09-19 16:11:38.382
...
Having a problem with IIS on Windows Server 2003 (using a classic ASP web application)
The database server (SQL Server 2005) is on the same machine.
I create a recordset, and set its activeconnection as follows:
Dim RS
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = "Provider=SQLOLEDB;Network Library=DBMSSOCN;Data...