Viewing 15 posts - 361 through 375 (of 496 total)
Here is a version using a static Date table (I create and populate it with a CTE, but it is static):
create table DateTable (DateVal datetime)
declare @StartDate DateTime,
...
November 14, 2013 at 8:08 pm
This is your CTE based query:
CREATE TABLE DateRange (Id TINYINT, Start_Range DATETIME, End_Range DATETIME)
INSERT DateRange
VALUES (1, '2011-07-13 12:05:12.123','2011-09-15 11:00:01.234')
,(2,'2011-09-15 11:00:01.234','2013-10-04 02:12:12.345')
,(3,'2013-10-04 02:12:12.345','2013-11-04 02:12:12.345')
;WITH cte2 (ID, Start_Range, End_Range) AS
(SELECT ID, c.Start_Range,...
November 14, 2013 at 8:07 pm
How about some DDL for the parent table and sample data with the expected outcome? That would help. Do you not know the largest date range possible for the query?...
November 14, 2013 at 7:12 pm
Why can't you create a permanent date table? That would be better then building one on the fly every time.
November 14, 2013 at 6:33 pm
Try this:
'"SELECT @colnames =COALESCE(@colnames + '','', '''') + column_name from TestData.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=''newtable'' and column_name in (' + @importedquery1 + '); select @colnames;" queryout C:\inetpub\wwwroot\cleansed\HeadersOnly.csv -c -T -SD3LICSQL02'
November 14, 2013 at 6:25 pm
Same issue.
When ever something needs to be enclosed in single quotes make sure you use two when creating the dynamic string i.e.
where TABLE_NAME = 'newTable' and column...<- regular SQL
string =...
November 14, 2013 at 3:56 pm
This is a duplicate post. I have responded to your first post:
http://www.sqlservercentral.com/Forums/Topic1514453-150-1.aspx
Let's use that one going forward.
November 14, 2013 at 2:11 pm
You have a few options here. The first thing is that a query like this maybe impacted by bad parameter sniffing so test it with and without recompile.
1. Set @value...
November 14, 2013 at 2:09 pm
This query will get you a list of job steps that are setup to run against a certain database:use msdb;
go
select *
from sysjobsteps
where subsystem = 'TSQL'
and database_name = ?
But you...
November 14, 2013 at 8:51 am
The master will have your login premissions, but if you want to get back your DB premissions you will need to have the user databases. Now maybe you have orphaned...
November 14, 2013 at 8:39 am
Oracle765 (11/13/2013)
ok if the variable @importedquery I pass in equals 'softwaremanufacturer,productname,productversion' then that's the only column headings I will want
I have got this far but its still showing an...
November 14, 2013 at 8:35 am
So basically you will need the Master database to get the permissions for your logins and the user database(s) for the permissions for the users that are associated with those...
November 13, 2013 at 3:51 pm
I think you need this (notice the double single quotes before and after the comma:
COALESCE(@colnames + '','', '')
November 13, 2013 at 3:47 pm
It doesn't sound like a SS issue. Sounds like an OS/HW issue. Is this a new file or are you appending/overwriting an existing file?
November 13, 2013 at 8:56 am
If you are asking if the engine is working correctly it is. You can have nullable FKs. They do not check to see if there is a null column in...
November 12, 2013 at 10:42 am
Viewing 15 posts - 361 through 375 (of 496 total)