sql-server

How to dump a table to a text file in SQL server? in sql Server 2005

How to export a table to a text file? I need to get the INSERT script (structure and data) for an already existing table. ...

How to get my SQL DB to match my Domain Driven Design

Okay, I'll be straight with you guys: I'm not sure exactly how Domain Driven my Design is, but I did start by building Model objects and ignoring the persistence layer altogether. Now I'm having difficulty deciding the best way to build my tables in SQL Server to match the models. I'm building a web application in ASP.NET MVC, although ...

How to Re Format DateTime in Sql with Ceiling or Flooring method?

i need this table look please TABLE2 Table1 VisitingCount Date 1-------------------15:09 3-------------------15:10 7-------------------15:15 1-------------------15:39 2-------------------15:40 3-------------------15:47 How can i change this table below table Table2 VisitingCount Date 11-------------------15:00-15:30 6--...

SQL Server Licensing: Are Windows Server CAL's required?

If I purchase a SQL Server 2008 Processor license, this permits any number of users to connect to the database instance. Users will typically connect through one or more application servers running WS08 Web Edition, and are authenticated through the hosted application (not AD or otherwise). The users belong to various different organisat...

Different result with * and explicit field list?

I was exploring another question, when I hit this behaviour in Sql Server 2005. This query would exhaust the maximum recursion: with foo(parent_id,child_id) as ( select parent_id,child_id from #bar where parent_id in (1,3) union all select #bar.* -- Line that changed from #bar join foo on #bar.parent_id = foo.ch...

Report Builder 1.0 and MandatoryFilter

Hi, We're using ReportBuilder 1.0 (2005) for now. I'm not understanding the way that the MandatoryFilter setting is working. It doesn't consistently prompt for a filter, only when certain fields are included in the report and only when selected in a certain way. For example, if I double click on an entity it will add all of the non ...

Reporting Services 2005 Subtract 2 Values in a Table

I have a list of fees being displayed in a table object. I would like to display the difference between 2 of the fees in a text box (not sure if this goes in the table footer or in a group footer). I am able to sum values easy but I don't see how I can subtract values. In this example let's say I would like to show the difference of the ...

TSQL Parameterized SPROC question

I need to write a stored procedure to update one of a set of similar columns. The columns are named 'UserField1', 'UserField2' etc. I was hoping to pass a parameter to the SPROC which would set the column to be updated. However, I can't seem to get the code correct. Here's a simplified example of what I tried (which gets me an 'Incor...

ms sql server; index on TEXT column

I have a database table with several columns; most of them are VARCHAR(x) type columns, and some of these columns have an index on them so that I can search quickly for data inside it. However, one of the columns is a TEXT column, because it contains a very large amount of data (23 kb of plain ascii text etc). I want to be able to sear...

How to get around openquery defaulting columns to not null.

I have a sql server pass-thru query like this: *select * into myTable from openquery (yourComputer, 'select x,y,z, from yourTable')* The problem is the columns in myTable are defaulting to not null and I will later want to add rows to this table with some columns null. Can I get round this? ...

Loop in stored procedure or in client code

From an efficiency and best practices point of view, I appreciate everyones thoughts. I have a stored procedure that makes (n) copies of a row and inserts the row into the necessary table. For example. Make a copy of an inventory item and add the copies to inventory. I see two options for this type of stored procedure. Option 1: CR...

Sql Server: how to write trigger on a table with denied SELECT

Hello I have a table on which I have denied SELECT privs to a user. This table has a trigger which references the INSERTED table, basically doing an AFTER UPDATE SET <table>.[UPDATED] = getdate() WHERE ROWID IN SELECT ROWID FROM INSERTED It is giving me an error though, saying "SELECT PERMISSIONS DENIED", I am guessing because of ...

Is there a difference between id,date or date,id index in sql server

I'm creating an index in sql server 2005 and the discussion with a coworker is if it makes a difference between index key columns being id and date vs date then id. Is there a fundamental difference in the way the index would be created in either scenario? Would it make a difference in other versions of SQL server? Thanks ...

T-SQL: Round to nearest 15 minute interval

What's the best way to round a HH:MM value to the closest 15 minute interval? I don't track seconds so they don't matter. 00:08:00 becomes 00:15:00 00:07:00 becomes 00:00:00 01:59:00 becomes 02:00:00 and so on. Is there an elegant, non UDF or Case statement method for doing this? Thanks, James EDIT: Here's the SQL I'm using to ...

SQL Server Non-Standard Date Based Histogram

I have user login data with timestamps and what I would like to do is get a histogram of logins by year, but with the year starting at an arbitrary date. For example, I want the following sort of information: 1 May 2005 - 30 Apr 2006 | 525 1 May 2006 - 30 Apr 2007 | 673 1 May 2007 - 30 Apr 2008 | 892 1 May 2006 - 30 Apr 2009 | 1047 Th...

How to enter long SQL text sample data with Visual Studio?

The Server Explorer built into Visual Studio is a nice way to connect to your database, view existing data, and edit data. Very useful for entering sample data into a database for testing and development purposes. However, what if you have a "text" column and want to enter a long text field? For example, I have a text column in which ...

MS SQL: Database + Windows Authentication + Username/Password?

I have always thought that in order to connect to SQL server using windows authentication with explicitly specified creds, you must LogonUser, Impersonate, then connect. It seems to me that this link suggests that it's possible to connect to SQL server without all this hassle, simply by specifying "uid=...;pwd=..." in connection string....

SSRS css messing up?

So the last couple of days my dev webpage for ssrs has been looking really weird, as if it's not getting styled by css at all. I'm not the only person that is seeing it like this. We just rebooted the server and it didn't have any effect. If you know what it causing this, please help. another symptom is that i can't modify security s...

How to insert a new record to table A when table A deppends on table B and vice versa

Hello, I'm not sure if this is well designed, if it's not please, advice me on how to do this. I'm using Sql Server 2008 I have: TableA (TableA_ID int identity PK, Value varchar(10), TableB_ID PK not null) TableB (TableB_ID int identity PK, Value varchar(10), TableA_ID PK not null) The goal is simple: TableA can have rows only i...

SQL server for an oracle developer/dba

I have a few years experience developing with oracle and have now moved to a place where they use SQL server (2005). Where would be a good place to learn things like SQL Server query optimisation, basic dba stuff and sql server gotchas for someone with my background. Thanks! ...