我想用这个脚本连接存储过程参数,我用它来创建登录名和密码,并在这里给它sysadmin权限是我的脚本
ALTER PROCEDURE [dbo].[crearte_user]
@login_name NVARCHAR(200),
@pass NVARCHAR(200)
AS
EXEC ('create login'+@login_name+'WITH password='''+@pass+''',check_policy=OFF,check_expiration=OFF')
EXEC ('sp_addsrvrolemember @loginame ='@pass, @rolename = N'sysadmin')
编译器抛出此错误:
Msg 102,Level 15,State 1,Procedure crearte_user,Line 4
' @ pass'附近的语法不正确。
答案 0 :(得分:1)
看起来您只缺少一些引号,您还将SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('sq0atp-TOKEN');
$api_instance2 = new SquareConnect\Api\OrdersApi();
$body = new \SquareConnect\Model\CreateOrderRequest();
$itemstobuy = array(array("catalog_object_id" => "FYFGTSEZBVFP3BYECIJOCYAC", "quantity" => "1"), array("catalog_object_id" => "TMIQXB7RZY4EPXQZZAO3QVYM", "quantity" => "1"));
$body->setIdempotencyKey(uniqid());
$body->setLineItems($itemstobuy);
$body->setReferenceId("Test".uniqid());
try {
$api_instance = new SquareConnect\Api\CheckoutApi();
$checkout = new \SquareConnect\Model\CreateCheckoutRequest();
$checkout->setOrder($body);
$checkout->setIdempotencyKey("Test_".uniqid());
try {
$result = $api_instance->createCheckout($location_id, $checkout);
} catch (Exception $e) {
echo "The SquareConnect\Configuration object threw an exception while " . "calling CheckoutApi->createCheckout: ", $e->getMessage(), PHP_EOL; exit; }
} catch (Exception $e) {
echo 'Exception when calling OrdersApi->createOrder: ', $e->getMessage(), PHP_EOL;
作为@pass
,这是故意的吗?
我假设你正在寻找(我已经为@loginname
切换@pass
):
@login_name
另请注意ALTER proc [dbo].[crearte_user] @login_name nvarchar(200),@pass nvarchar(200)
as
exec('create login ' + @login_name + ' WITH password = ''' + @pass + ''', check_policy=OFF, check_expiration=OFF')
exec('sp_addsrvrolemember @loginame = ''' + @login_name + ''', @rolename = N''sysadmin''')
,您需要在''sysadmin''
字符串内放两次。