Viewing 15 posts - 136 through 150 (of 209 total)
Seems to work reasonably well even for 2 dimensional splits. Using the general approach presented below, I have experimented with much wider parameters and increased number of rows. ...
July 24, 2010 at 10:18 am
Not yet Jeff, it's just that I'm so used to doing tally table/cross apply splits that I thought I'd try something different for a change!;-)
July 23, 2010 at 5:41 pm
In fact this particular example can be addressed by a combination of PARSENAME and string manipulation to resolve the column list
DECLARE @ReplacePipe VARCHAR(MAX)
SET @ReplacePipe = REPLACE('1,a,b,20080101|2,c,d,20080102|3,e,f,20080102', '|', '.')
;WITH cte (SplitColumn)...
July 23, 2010 at 8:40 am
The reason this script is not working is because of a conflict in collation sequences. You are creating columns in your table #ProductTest with collation Latin1_General_CI_AS but this...
July 23, 2010 at 8:32 am
This sort of approach may be of interest to you. For testing purposes, I created a comma-separated file called Challenge.csv based on your Excel sheet CSV_File_Format. The next...
July 19, 2010 at 4:11 pm
Using OPENROWSET BULK you can specify the column list eg
INSERT Price1
([TimePoint],
[rtPrice],
[daPrice],
[versifyId],
[externalNodeId]
)
SELECT
TimesPoint,
rtPrice,
daPrice,
versifyId,
externalNodeID
FROM OPENROWSET (BULK 'C:\Price.csv', FORMATFILE = 'C:\PriceFormat.txt') AS Z
July 15, 2010 at 5:07 am
I think you're just missing the SET FMTONLY OFF setting
SELECT a.* INTO #hdr FROM OPENROWSET('SQLNCLI','Server=(local)\SQLEXPRESS;Trusted_Connection=yes',
'EXEC(''SET FMTONLY OFF RESTORE HEADERONLY FROM DISK =''''c:\code3Billing\ClientSQLData\Master\code3billing.bak '''''')') AS a
June 22, 2010 at 9:04 am
If you embed your RESTORE FILELISTONLY in an EXEC statement, you can still use your OPENROWSET approach
SELECT a.* INTO #tmp FROM OPENROWSET('SQLNCLI','Server=(local)\SQLEXPRESS;Trusted_Connection=yes',
'EXEC(''SET FMTONLY OFF RESTORE FILELISTONLY FROM DISK=''''C:\code3Billing\ClientSQLData\Master\code3billing.bak'''''')') AS...
June 22, 2010 at 5:09 am
And another variation, this time using PIVOT
IF NOT OBJECT_ID('tempdb.dbo.#t', 'U') IS NULL DROP TABLE #t
SELECT 1 AS id, 'fname1' AS name INTO #t
UNION ALL SELECT 2, 'fname2'
UNION ALL SELECT 5,...
June 21, 2010 at 1:46 pm
An alternative approach is to initially access the file using OPENROWSET BULK. The file is then split vertically using CROSS APPLY/Tally split method and within the same query...
June 20, 2010 at 12:21 pm
Thanks Dave, yes it does make things a lot tidier
June 16, 2010 at 5:12 am
This variation is independent of the ANSI_NULLS setting. I use the same table variable @t_temp kindly supplied by bteraberry
;WITH cte AS
(
SELECT T.ID, Z.Col FROM @t_temp AS T...
June 16, 2010 at 4:12 am
OPENROWSET should do the trick eg
INSERT OPENROWSET('SQLNCLI', 'SERVER=REMOTE_SERVER;TRUSTED_CONNECTION=YES', 'SELECT name, num, email, ssn from Remote_Database.dbo.remote_table')
SELECT name, num, email, ssn FROM local_table
June 14, 2010 at 12:29 pm
You can put your multiple statements in a stored procedure and then call the fully qualified stored procedure from your OPENROWSET statement.
SELECT * FROM OPENROWSET('SQLNCLI','Server=TheServer;Trusted_Connection=yes;',
'EXEC Databasename.dbo.Storedprocname')
May 19, 2010 at 5:03 am
You can also tackle this problem using OPENROWSET BULK.
The data is first referenced using OPENROWSET BULK via the CTE cteFileData. This uses the unstructured format file DataSampleBulk.fmt which...
May 3, 2010 at 9:19 am
Viewing 15 posts - 136 through 150 (of 209 total)