Showing posts with label statement. Show all posts
Showing posts with label statement. Show all posts

Wednesday, March 21, 2012

Excel (source) and parameters ?

I want to query my excel source sheet with a paramater so i create a sql statement like

select * from xxx where name like 'fred%'

Then I want to parameterise it with

select * from xxx where name like @.Name or select * from xxx where name like ?

both allow me to map the Parameter neither syntax works in the data flow or preview but ? still works in the build query window !

Anyone know the correct Param declaration for the Excel Source (i believe it should be oledb @.Name declaration ?

is this a bug or am i missing something here ...

Cheers

Colin

Colin,

Could you provide more details about the error you are receiving and data type of the column you are mapping the parameter to?

I just did a quick test and was able to run a query with a parameter out of a Excel. The query looks like:

SELECT SurrogateKey, DatabaseSource, Acct
FROM ['YTD AP Trans$']
WHERE (RowNumber >?)

The parameter mapping is: Parameter0 --> User: FilterVariable

FilterVAriable is a package Variable string and its values is '10' (yes the quotes are part of the variable value)

Rafael Salas

|||

my actual param was called @.venue, when i left it as param 0 it worked ok.

I deleted the params from the property browser, recreated the parameter left the name parameter0 and it worked ok

thanks for posting

Excel (source) and parameters ?

I want to query my excel source sheet with a paramater so i create a sql statement like

select * from xxx where name like 'fred%'

Then I want to parameterise it with

select * from xxx where name like @.Name or select * from xxx where name like ?

both allow me to map the Parameter neither syntax works in the data flow or preview but ? still works in the build query window !

Anyone know the correct Param declaration for the Excel Source (i believe it should be oledb @.Name declaration ?

is this a bug or am i missing something here ...

Cheers

Colin

Colin,

Could you provide more details about the error you are receiving and data type of the column you are mapping the parameter to?

I just did a quick test and was able to run a query with a parameter out of a Excel. The query looks like:

SELECT SurrogateKey, DatabaseSource, Acct
FROM ['YTD AP Trans$']
WHERE (RowNumber >?)

The parameter mapping is: Parameter0 --> User: FilterVariable

FilterVAriable is a package Variable string and its values is '10' (yes the quotes are part of the variable value)

Rafael Salas

|||

my actual param was called @.venue, when i left it as param 0 it worked ok.

I deleted the params from the property browser, recreated the parameter left the name parameter0 and it worked ok

thanks for posting

Monday, March 19, 2012

Examples of Certificates created with Private Key and FROM EXECUTABLE FILE options

Hi

I am looking at documentation of CREATE CERTIFICATE statement. I am having hard time in understanding if I want to create CERTIFICATE with above mentioned options, how I am supposed to create either PRIVATE KEY file or EXECUTABLE file. any example would be really helpful for what I am doing here.

thanks

Satya

Take a look at makecert: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfcertificatecreationtoolmakecertexe.asp. This utility generates certificates in those two types of files.

But note that you don't need to create those files to create a certificate. Those options are only used to import a certificate from such files. You can create a certificate within SQL Server by not using those options. You can find several examples on my blog, for example: http://blogs.msdn.com/lcris/archive/2005/06/10/428178.aspx.

Also, you can create those files by backing up a certificate created in SQL Server. See syntax for BACKUP CERTIFICATE: http://msdn2.microsoft.com/en-us/library/ms178578(SQL.90).aspx.

Thanks
Laurentiu

Friday, March 9, 2012

Exact SQL for running process

For a long running stored procedure, how can I determine the SQL statement within the stored procedure that is currently running?

The Activity Monitor only shows the name of the stored procedure and whether it is a SELECT/INSERT/UPDATE, never the complete statement.

Thank you.

You could capture the "SP: StmtCompleted" event in Profiler.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

Yes, I realize that is an option but would like to know if there is a way to do this with just T-SQL (using some system tables). I do not often have the Profiler running and it would be very useful to have a simpler way to get this information.

Thank you.

|||

You can get this through the system function sys.dm_exec_sql_text

You pass in the handle from sys.dm_exec_requests. Check books online under sys.dm_exec_requests and it will walk you through an example.

-Sue

|||

This still gives me the entire stored procedure text (similar to fn_get_sql). If I have a stored procedure containing the following statements:

SELECT * FROM Large_Table_1 (NOLOCK)

SELECT * FROM Large_Table_2 (NOLOCK)

SELECT * FROM Large_Table_3 (NOLOCK)

I would like to see the currently running select during execution. A T-SQL version of what the Profiler shows is really what I need.

Thank you.

|||

There is a begin and end offset of the current statement in those dmv's.

You should use substring to parse the text with the given offsets.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

Exact SQL for running process

For a long running stored procedure, how can I determine the SQL statement within the stored procedure that is currently running?

The Activity Monitor only shows the name of the stored procedure and whether it is a SELECT/INSERT/UPDATE, never the complete statement.

Thank you.

You could capture the "SP: StmtCompleted" event in Profiler.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

Yes, I realize that is an option but would like to know if there is a way to do this with just T-SQL (using some system tables). I do not often have the Profiler running and it would be very useful to have a simpler way to get this information.

Thank you.

|||

You can get this through the system function sys.dm_exec_sql_text

You pass in the handle from sys.dm_exec_requests. Check books online under sys.dm_exec_requests and it will walk you through an example.

-Sue

|||

This still gives me the entire stored procedure text (similar to fn_get_sql). If I have a stored procedure containing the following statements:

SELECT * FROM Large_Table_1 (NOLOCK)

SELECT * FROM Large_Table_2 (NOLOCK)

SELECT * FROM Large_Table_3 (NOLOCK)

I would like to see the currently running select during execution. A T-SQL version of what the Profiler shows is really what I need.

Thank you.

|||

There is a begin and end offset of the current statement in those dmv's.

You should use substring to parse the text with the given offsets.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com