I have a varchar field that contains a string like "10,11,12,13". How can I use that CSV string to join to another table with those IDs? Here's the approach I'm taking now:
select *
from SomeTable a
WHERE (',' + @csvString + ',') LIKE '%,' + CONVERT(varchar(25), a.ID) + ',%'
Where @csvString is "10,11,12,...". I intend to use this ...
I'm trying to generate scripts from a database, but with slight modifications to those objects. For example, I want to generate the script for a stored procedure, but I want the script to create it under a different schema.
I have an example of what I'm currently trying below. If I'm going in a completely wrong direction then please poi...
I would like to ask if there is a way to include the total number of rows, as an additional column, in the returned result sets from a TSQL query using also the Row_Number (SQL 2005) command.
For example, getting the results set from a query against Book table in a form similar to this:
RowNum BookId BookTitle TotalRows
------...
I am considering building several C#/.NET4 applications all using a central, cloud based database. In addition, several LAMP (MySQL) web shops will be accessing the cloud DB.
MySQL is the database that I'm most familiar with, and my default selection for the cloud DB would be MySQL on Amazon or Joyent. However, I was wondering what deve...
I have this table
UserID SessionID SessionStart SessionEnd
-----------------------------------------------
1 abc1 2010-1-1 2010-1-2
5 def3 2010-1-5 2010-1-9
1 llk0 2010-1-10 2010-1-11
5 spo8 2010-1-13 2010-1-15
1 pie7 2010-1-16 2010-1-...
I have a large auditing stored procedure that prints values and runs some SELECT statements. When running within SQL Management Studio we have the use select to display "Results to Text" so all of the SQL results and print statement display in one place.
Now I need to have some C# code also call this auditing procedure at the end of the...
What are the benefits of storing XML in SQL Server over storing JSON in a varchar field?
Any tutorial available for how to use the XML data type effectively?
Do I need to provide the dtd / xml schema somehow? I've heard it is optional, right?
Thank you.
UPDATE: here's the answer to the last part of the Q.
XML schema information ...
Dose nHibernate play well with database level cascading deletions? What I mean is that if I have a constraint set at the RDBMS level to cascade delete all orphans, will nHibernate invoke any custom delete logic at the application level if I were to delete an entity though nHibernate? Or should I remove the cascading deletions from the RD...
I have the following SQL
SELECT
Seq.UserSessionSequenceID,
Usr.SessionGuid,
Usr.UserSessionID,
Usr.SiteID,
Seq.Timestamp,
Seq.UrlTitle,
Seq.Url
FROM
tblUserSession Usr
INNER JOIN
tblUserSessionSequence Seq ON Usr.UserSessionID = Seq.UserSessionID
WHERE
(Usr.Timestamp > DATEADD(mi, -45,...
I have a report that shows or hides columns in a group based on a header cell. SSRS makes this pretty easy and is kind enough to place a little plus/minus icon in the toggling cell.
I want to HIDE this plus/minus icon when there is only one column of data in the subgroup, because it shows that one column by default so expanding the gro...
Hi,
I am trying to implement test application which will monitor all changes in table (MS SQL Server 2008).
I have followed all steps described HERE, but strange thing is happening ... it goes for endless loop. When GetData calls adapter.Fill(dataToWatch, tableName); the dependency_OnChange event is raised which in its turn calls GetDat...
Hi, I asked a question a few days ago (http://stackoverflow.com/questions/2795723/access-to-sql-server-2005-from-a-non-domain-machine-using-windows-authentication) which got some interesting, but not usable suggestions. I'd like to ask the question again, but make clear what my constraints are:
I have a Windows domain within which a mac...
SQL Server 2008
I almost have, I think, what I'm looking to do. I'm just trying to fine tune the result. I have a table that stores timestamps of all transactions that occur on the system. I'm writing a query to give an average transaction time. This is what I have so far:
With TransTime AS (
select endtime-starttime AS Totaltime
...
Could this be better? .NET 2.0 compatibility for SQL Server 2005:
public static SqlString RegexSubstring(SqlString regexpattern,
SqlString sourcetext,
SqlInt32 start_position)
{
SqlString result = null;
if (!regexpattern.IsNull && !sourcetext.IsNull ...
I just want to have a "ModifyDate" column automatically populated for me when a record is either inserted or updated.
Should I be using triggers or is it OK to use a Computed Column?
(Using SSMS2005 and SQL Server 2005 Express)
...
It looks like this has been asked and answered in all the simple cases, excluding the one that I'm having trouble with. I've tried using a recursive CTE to generate this; however maybe a cursor would be better? Or maybe a set of recursive functions will do the trick?
Can this be done in a cte?
consider the following table
PrimaryKey ...
Scenario: I have a fairly generic table (Data), that has an identity column. The data in this table is grouped (lets say by city).
The users need an identifier in order for printing on paper forms, etc.
The users can only access their cites data, so if they use the identity column for this purpose they will see odd numbers (e.g. a 'New...
I have a customized data import executable in .NET 3.5 which the SqlBulkCopy to basically do faster inserts on large amounts of data. The app basically takes an input file, massages the data and bulk uploads it into a SQL Server 2000. It was written by a consultant who was building it with a SQL 2008 database environment. Would that env ...
How can I script the deployment of a Visual Studio database project?
I have a DB project in visual studio and I would like to use it in order to deploy on remote machines via a script. I notice that when I 'deploy' from visual studio, it generates a .sql file.
I intercepted this file and tried running it from the command line with osq...
Hi,
I am getting the following error: Invalid authorization specification
I've narrowed down the error to my connection string. I have verified the server name, database, user & password are correct. Here is the string:
"Provider=SQLOLEDB;Server=xxxxx.db.12345.hostedresource.com;Database=foo;UID=fooUser;PWD=fooPW"
The SQL server is...